Flash Music – Distress Call

Yo, it’s so uncool that the first tale should be qualms on ground. Ok, that aside, I need help with music players in Flash. If you have any ideas, please feel free to leave a comment.

Problem: I want to stop the music that is playing when the playhead leaves the frame which the music player is loaded. Please help.

I have a music player MovieClip that I made. Some specific frames on some specific layers these music players. The scripting for the music player is embedded in it (i.e. if you should double-click the MovieClip, you will see an actions layer; that’s where all the coding for the player is). It plays (current, previous and next songs), pauses and stops flawlessly. It even loops! But the problem comes when I navigate out of that frame. The music continues playing! If I should return to that frame, the music player starts a new channel and plays; playing two songs at once (or the same songs) — like having two really bad singers singing without synchronization.

Another piece of information you may need is that, some frames on different timelines have different scripting; depending on the content that’s meant to be on that frame.

Trials: My attempts to solve the problem.

1. In the music player, (assuming it is loaded on frame 45)

parent.addEventListener(Event.EXIT_FRAME, onExitFrame)
function onExitFrame(e:Event):void {
mySoundChannel.stop() // stop the music player when the playhead of the main timeline leaves the frame where the MovieClip is loaded
}

This didn’t work because the frame, on the “actions” layer where I stop the main SWF movie occurs after the frame where I have the music player loaded — silly me. What happens is: the music player loads but doesn’t play anything because the playhead has left the frame where the music player is loaded.

2. I moved the frame on which the movie clip is loaded (on its timeline) to match the frame of actions (which stops the movie). I still get the same result as {1.}. I put a trace statement in it, it shows that the playhead constantly tries to EXIT_FRAME but is somehow stopped because of the stop() command I have; thereby always triggering the onExitFrame function. This happens irrespective of the order of timelines

3. I tried having a SoundMixer in the navigate function and using it to stop all sounds each time I change sections.

function navigaeThroughSections(e:MouseEvent):void {
. . .
var soundJanitor:SoundMixer = new SoundMixer();
soundJanitor.stopAll(); // to stop all playing sounds
}

But this returns with a compile-time error: 1061: Call to a possibly undefined method stopAll through a reference with static type flash.media:SoundMixer. What are the causes of this error?

Please if you can help in any way or if you have any ideas on how to fix this, hola at your boy.

Advertisements

Share your knowledge

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s