Preloading external mp3, but shouldnt play until another scene is reached

Hi, newbie here.

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.

-britney

what are you having problems with exactly? actually preloading the sound file or just scripting it to not play until a condition has been met?

well both, :frowning: sign

Welcome to kirupaforums=)

Did you have a look at this
http://kennybellew.com/tutorial/
??

scotty(-:


//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)

thanx guys (scotty and max flash)…i’m working on the thing u said… i’ll get back in a few… hope this works

for reference if you need any. i jigged something up real quick.

hi again. heres my file… i did what u told me…it doesnt stop at frame 1 and keeps on going to the next frames.

http://www.geocities.com/b_kreationz/1.swf

here it should load “4.mp3”, a 3.5 mb mp3 file. and then goto frame 25… but it’s not workin.

i’ve attached the fla.
thanx in advance for helping me out guys…really appreciate it

just like a charm.

the working, modified version of your file.

works offline …letme check online…brb

ok…online it keeps on displaing NaN…
what do i do?

check the pathing… i put up http://www.geocities.com/sammy_o85/1.swf for a test and it worked fine for me.

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.

i tested your site just now, it worked

figured it out…it was geocities slow server…can i put the

_root.sound_1.start();

in any other frame …say like frame 20?

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.

good luck.

thanx max…you’ve been awesome

tis what im here for.

later times.