Background music which plays over multiple frames without restarting in as3

1.6k views Asked by At

I have been trying to get background music working for my game in as3. What I want is to have one soundtrack for menu screens, and another in game. The menu music should not stop or create a new instance when switching between menu frames (frames 2-5 in my program), but should stop when entering game level frames (frames 6-10).

To do this, I created a 'music' layer on the timeline, and made one keyframe on frame 2 and with code:

music=introMusic.play();

where 'music' is a soundChannel variable

However, when navigating to the help menu and then back to the title (frame 2), another instance of the song starts playing, despite not having left the frame of the music layer that the code is in.

I'm aware of how to stop a soundChannel from playing, but I want the sound to continue playing interrupted through all menu screens until the player actually enters a level.

P.S. I'm relatively new to as3, and I assume that the empty space between keyframes (from circle to square) on a layer is just the one frame? Just occurred to me that maybe that's wrong?

Thanks in advance.

0

There are 0 answers