Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 18:41
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  AS2 XML MP3 PLAYER BY ZAIN SYED has glitches need help
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: AS2 XML MP3 PLAYER BY ZAIN SYED has glitches need help  (Read 731 times)
jellynator
Server what's that
*
Posts: 1


View Profile Email
« on: 04/27/11, 09:46 »

/*
XML MP3 PLAYER BY ZAIN SYED
NOV 2005
If you have any problems/suggestions or feedback please contact me at
ENJOY!!!
*/

this._lockroot = true;


//make textfields autosize
album_txt.autoSize = "left";
artist_txt.autoSize = "left";
title_txt.autoSize = "left";


//create sound object
var songInterval:Number;
var amountLoaded:Number;
var mySound:Sound;
var nextTrack:Number;

//this will contain all the track details from the xml file
var tracks_array:Array = new Array();
var totalTracks:Number;

//create the XML object and populate with track details
var jukebox_xml:XML = new XML();
jukebox_xml.ignoreWhite = true;
var RootNode:XMLNode;

jukebox_xml.onLoad = function(success:Boolean) {
if (success) {
RootNode = this.firstChild;
totalTracks = RootNode.childNodes.length;
populateTracksArray();
} else {
trace("error loading xml file");
}
};
jukebox_xml.load("tracks.xml");

function populateTracksArray():Void{
for(var i:Number=0; i < totalTracks;i++){
tracks_array = RootNode.childNodes;
tracks_array.source = RootNode.childNodes.attributes.source;
tracks_array.artist = RootNode.childNodes.attributes.artist;
tracks_array.album = RootNode.childNodes.attributes.album;
tracks_array.title = RootNode.childNodes.attributes.title;
}
//play first track



playTrack(tracks_array[0].source,tracks_array[0].artist,tracks_array[0].album,tracks_array[0].title,true);

//populate list component with song titles
populateList();
}
function playTrack(source, artist, album, title, stream):Void{
artist_txt.text = artist;
album_txt.text = album;
title_txt.text = title;
mySound = new Sound();

mySound.onSoundComplete = function():Void{
//lets play the next song
if(continous_comp.selected){
if(list_comp.selectedIndex < (totalTracks -1)){
list_comp.selectedIndex +=1;
}else{
list_comp.selectedIndex = 0;
}
playTrack(tracks_array[list_comp.selectedIndex].source,tracks_array[list_comp.selectedIndex].artist,tracks_array[list_comp.selectedIndex].album,tracks_array[list_comp.selectedIndex].title, true);
}
}

mySound.loadSound(source,stream);
clearInterval(songInterval);
songInterval = setInterval(songProgress,100);
}

function populateList():Void{
for(var i:Number=0; i<totalTracks;i++){
list_comp.addItem(tracks_array.title,tracks_array.source);
}
_root.list_comp.selectedIndex = 0;
}

//create a listener for the list component
var compListener:Object = new Object();
list_comp.addEventListener("change", compListener);

compListener.change = function(info:Object):Void{
playTrack(info.target.value,tracks_array[list_comp.selectedIndex].artist,tracks_array[list_comp.selectedIndex].album,tracks_array[list_comp.selectedIndex].title, true);
}


//this controls download bar and playback

function songProgress():Void{
amountLoaded = (mySound.getBytesLoaded()/mySound.getBytesTotal());
progressbars_mc.downloadbar_mc._width = amountLoaded * 200;
progressbars_mc.playback_mc._x = (mySound.position/mySound.duration)*amountLoaded * 200;
position_txt.text = mySound.position;
duration_txt.text = mySound.duration;
playback_txt.text = progressbars_mc.playback_mc._x;
}

//controls
var soundPosition:Number;
var paused:Boolean = false;

controlbar_mc.pause_btn.onRelease = function():Void{
soundPosition = mySound.position;
paused = true;
mySound.stop();
}

controlbar_mc.play_btn.onRelease = function():Void{
if(paused){
mySound.start(soundPosition/1000);
paused = false;
}
}




i believe that i need to add in a clear update function but im not so sure.

but i know that the problem has to do with list_comp

« Last Edit: 04/27/11, 10:04 by jellynator » Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 04/27/11, 10:17 »

And the problem is ... ?

Jorge
Logged

prigo
Server what's that
*
Posts: 1


View Profile
« Reply #2 on: 01/10/12, 02:05 »

I have just downloaded the AS2 MP3 player & I want to know if it is possible to assign pause / play function to a single button
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #3 on: 01/10/12, 07:37 »

Probably ... ¿which actions are assigned to play and pause buttons?

Jorge
Logged

Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!