Question on sound

I’m a relative newbie to Flash, so I’ve been running into a few problems as of late. My #1 problem is getting both an MP3 and a flash movie to load at the same time (without having to click any button)

What I’ve been doing is making a layer for the movie and adding in actionscript: loadMovieNum(“movie.swf”, 0);

Then I make a new layer for the sound and import it, drag it and drop it on the stage from the library and setting it on Start.

When I goto test it, only the movie plays and the sound does not… if I just use control+play, the mp3 does play, but of course no movie.

So, if anyone can tell me what I’m doing wrong or give me alternative script or ideas, it would be much appreciated.

That sounds pretty weird. You seem to have done everything correctly. Maybe you should try without the action script and just create one layer with the move and then another layer with the sound.

You should load in your mp3 externally so your file size goes down and you can stream it in instead. Then you should have no problem with the loaded in movie. It could be a level thing, or a movieClip or instance name issue. Here’s the code:


myMusic=new Sound();
myMusic.loadSound("yoursong.mp3", true);
//true is for streamed in

Make sure your mp3 resides in the same folder as your main movie, or change the path. If you need more info, do a search of the forums using loadSound - you’ll find a bunch of stuff. (-:

I tried both suggestions… won’t work :(… I’m thinking it’s possible it is a level problem because if I set the movie to a higher level it goes rather slowly and the music plays for roughly…1 second then stops

Freddy’s suggestion does work, I can assure you, but I think he forgot the play action. It’s possible that it autoplays when streaming, I don’t know, so I may be wrong though :slight_smile: You can remove the sound from the timeline, use freddy’s code on the first frame of your movie instead:


myMusic=new Sound(this);
myMusic.loadSound("yoursong.mp3", true);
myMusic.start(0,999);
//999 is the times to loop

And, make sure that yoursong.mp3 is in the same folder as the swf.

I think I did have the start on a movieClip off of the stage. Sorry, thank God Votesjoeba’s here!! Thanks Voet!!

But what’s the ‘this’ for in new Sound(this) ?

That’s the target of the sound object. If you have multiple sound objects but you don’t give them targets, changing the volume of one sound object will change the volume of every sound object for example. If you give them targets, you can control each one indepently.