as per a tutorial i’ve created a .as file to play audio files via and .xml file
the xml file :
<?xml version="1.0" encoding="UTF-8"?>
<songs>
<song url="AUDIO/audio1.mp3" name="jazzanova - eclipse" />
<song url="AUDIO/audio2.mp3" name="cafe del mar - vi" />
<song url="AUDIO/audio3.mp3" name="koop - baby" />
</songs>
the .as file :
// Setup sound object
var s:Sound = new Sound();
s.onSoundComplete=playSong;
s.setVolume(75);
// Array of songs
var sa:Array = new Array();
// Array of names
var sn:Array = new Array();
// Currently playing song
var cps:Number = -1;
// Position of music
var pos:Number;
// Load the songs XML
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
sa.push(nodes*.attributes.url);
sn.push(nodes*.attributes.name);
}
playSong();
}
xml.load("songs.xml");
// Play the MP3 File
function playSong():Void
{
s = new Sound();
if(cps == sa.length - 1)
{
cps = 0;
s.loadSound(sa[cps], true);
songname.text = String(sn[cps]);
}
else
{
s.loadSound(sa[++cps], true);
songname.text = String(sn[cps]);
}
playPause.gotoAndStop("pause");
}
// Pauses the music
function pauseIt():Void
{
pos = s.position;
s.stop();
}
// Pauses the music
function unPauseIt():Void
{
s.start(pos/1000);
}
// Music Controls
// Play/Pause Toggle
playPause.onRollOver = function()
{
if(this._currentframe == 1) this.gotoAndStop("pauseOver");
else this.gotoAndStop("playOver");
}
playPause.onRollOut = playPause.onReleaseOutside = function()
{
if(this._currentframe == 10) this.gotoAndStop("pause");
else this.gotoAndStop("play");
}
playPause.onRelease = function()
{
if(this._currentframe == 10)
{
this.gotoAndStop("playOver");
this._parent.pauseIt();
}
else
{
this.gotoAndStop("pauseOver");
this._parent.unPauseIt();
}
}
// Next Button
next.onRollOver = function()
{
this.gotoAndStop("nextOver");
}
next.onRollOut = next.onReleaseOutside = function()
{
this.gotoAndStop("next");
}
next.onRelease = function()
{
this._parent.playSong();
}
the second line of code s.onSoundComplete=playSong; is suppose to start the next track after the current on Completes playing. this is not happening, and i think it should, i keep checking the code to see if anything is breaking down or if i need to put the s.onSoundComplete=playSong; somewhere else. as a note i include the .as file in the first frame of my file during the preloader FYI just incase that has in bearing on how the code is working