im stuck with preloading sounds. i want to preload mp3s into my movie, but the thing is that they shouldnt start playing when completly/partially loaded.
i want the mp3 to get completely loaded in the background(but shouldnt play as yet) .
when some animation is completed and scene 2 is reached the mp3 should start playing.
any clues? i would be very greatful if someone could help me out here.
//create a new sound, named sound_1
sound_1= new Sound();
//load the sound you want in your movie into your new sound object
sound_1.loadSound("your_sound.mp3", false)
//define a function to preload the sound
function checkLoad(){
var percentLoaded= (sound_1.getBytesLoaded()/sound_1.getBytesTotal()) *100;
progress.text= Math.round(percentLoaded)
}
//stops the sound from playing after it has loaded
sound_1.onLoad= function(success){
if (success){
this.stop()
}
}
//create a setInterval to call the preload function until the sound has loaded
checkProgress= setInterval(checkLoad, 1000);
on the stage you will need a dynamic text box with the variable name progress. as for your condition, i would say you should put something like this at the end of that animation timeline:
_root.sound_1.start();
that will play your sound (presumed to be on _root)
i did this off top of my head, so there could be flaws. just get back if anything goes afray.
hope this helps a little. (if you dont know any actionScript you might be staring blank)
you need to make sure that the “4.mp3” is in the **same **folder as your 1.swf. if it is in a different one, you have to adjust your pathing on the loadSound. that is the only reason NaN would come up.
sure, but you need to make sure you have the sound preloaded before you let it play. i recommend you keep the gotoAndPlay() but instead of the frame label i made, just put in nextFrame so that the movie plays only after your sound has been loaded. that should do it for you.
well, im off to bed. any other questions, just post them up and me or someone else will do what we can.