PDA

View Full Version : loudSound help


fuzzyface
08-14-2005, 03:38 PM
im making an mp3 jukebox but im having a bit of trouble with next/prev buttons.

ive created an array (called song() )for the mp3's, and have the following code for the next button.

on(release){

var x = song.length;

var y = x + 1;

s.loadSound(song[y]);
}


my problem is loading the mp3 once its been incremented.

im not sure if im using the loudsound command correctly. any help would be greatly appreciated.

Scottae
08-14-2005, 05:08 PM
Delete the code on your button instance and stick this code in the main timeline....your button instance must exist at the time of execution of this code. Also make sure your button has proper instance name....in my example it is next_btn. You could change this to something else if need be.

// You don't need to set x each time the button is pressed
// Keep it out here so it's only set once
var x = song.length;

// Need to initialize y to zero so it initially loads the first song
// in the array
var y = 0;

// Put the onRelease method of the button on the main timeline
// rather than on the button instance itself. This is just better
// coding practice. It makes it easier to find code. Make sure
// to give your button and instance name of 'next_btn'
next_btn.onRelease = function ()
{
// if the value of y plus one is less than the length of the
// array minus one......then add one to y
// Otherwise set y back to zero
if (y + 1 < x - 1)
y++;
else
y = 0;

// Load your song from the array with index y
s.loadSound (song[y]);
};

fuzzyface
08-19-2005, 04:25 PM
thank u so much for that.


realised my code was a bit iffy anyway but i suppose if u do it when not completely sober, its gonna be a bit wrong

i realised that my actionscript errors were also coming from my array, since i was defining that on the button too.


cheers again for your help and keep up the good work

p.s

also found that using this code prevented me from playing the last track in the array, but by dropping "-1" on the if statement cured this


cant thank u enough again