Groups | Blog | Home
all groups > macromedia flash sitedesign > march 2005 >

macromedia flash sitedesign : Change Music button dynamically


Anthony Brown
3/31/2005 3:30:30 PM
Hello-
I am drawing somewhat of a blank on this.
I have a button called "Change Music". What I want to do is have example: 4
mp3's on my website. When my visitor clicks on this button I would like it
to change music to the next mp3. Example: The movie loads, and is playing
1.mp3, visitor cliks button then 2.mp3 plays etc....

To reduce swf size I would like "get URL" these mp3's.

My thought was to do a for..loop script? Am I on the right track (no pun
intended).

Thanks

zcan
4/1/2005 6:33:03 AM
Try something like this

on (release) {
a++;
if (a>3) {
a = 1;
}
newSong.stop();
newSong = new Sound();
newSong.loadSound(a+".mp3", true);
}


This will work for three songs. 1,2,3 .mp3. Change the a>3 to how many
tracks you want to have. This works off the root so if this is the ony audio
you have it will work fine but you will probably want to attach the audio to
movie clips.
Good luck!




[quoted text, click to view]

Anthony Brown
4/1/2005 8:48:56 AM
Great! That's exact;y what I needed.


[quoted text, click to view]

Anthony Brown
4/1/2005 8:55:44 AM
I am getting an error.
Instead of coming up with 1.mp3 it says NaN.mp3

"not a number"?


[quoted text, click to view]

Anthony Brown
4/1/2005 9:28:42 AM
Got is fixed.

Last question. is there a way to have the mp3 repeat? It plays once, and
then stops.


[quoted text, click to view]

zcan
4/1/2005 7:00:37 PM
Try this

on (release) {
a++;
if (a>3) {
a = 1;
}
newSong.stop();
newSong = new Sound();
newSong.loadSound(a+".mp3", true);
newSong.onSoundComplete = function() {
newSong.loadSound(a+".mp3", true);
};
}












[quoted text, click to view]

Anthony Brown
4/3/2005 5:44:22 PM
Thanks!

[quoted text, click to view]

AddThis Social Bookmark Button