Hi,
I am working on a project at the moment, using flash mx 2004.
I need to get it finished by the end of the day hopefully!

I have a list of 5 items.
Each of these buttons bring you to another frame within the scene
Each of these items require a 1 minute to 2 minute long narration.

How do I make the sound files seperate from all other actions?
I would like for the user to be able to listen to the narration, completely, no matter where else they go on the site. However, if they choose to listen to another narration, it should stop the current narration that is playing first.

I have tried several things to try to get the effect.
Making the button trigger the sound, only makes for overlapping sound files in the event that they happen to click on another button.
Putting the narration in the frame itself means that the user can not go to another frame without stopping the sound.

I want to do this without having to use a stop button as well.

Any thoughts on how to accomplish this?
Thanks in advance.

Dani AI

Generated

Both approaches already in the thread will work, but there is a cleaner, more maintainable pattern: create one persistent Sound controller on the main timeline and call a single play function whenever a button is pressed. That keeps narration independent of frame navigation, and lets the new narration stop the old one before starting. This avoids the fragile "three-frame" frame-shuffle and keeps audio logic in one place.

Example ActionScript 2.0 pattern (put this in a single actions layer on frame 1 so it is not redefined on every frame):

if (_root.narrationController == undefined) {
  _root.narrationController = new Sound();
}

function playNarration(url:String):Void {
  if (_root.narrationController != undefined) {
    _root.narrationController.stop();
  }
  _root.narrationController = new Sound();
  _root.narrationController.loadSound(url, true); // true = stream while loading
}

// example button hookup:
btnNarr1.onRelease = function() {
  playNarration("audio/narr1.mp3");
  _root.gotoAndPlay("page1"); // optional navigation
};

Practical notes and troubleshooting:

  • Use external MP3s (streaming) for long narrations to keep SWF size small and avoid timeline-sync issues with embedded sounds.
  • Ensure the controller is created only once (first-frame actions or a persistent movieclip instance). If you recreate it on each frame, playback will be interrupted.
  • Call stop() on the current Sound object before creating/loading the next one to prevent overlap.
  • If using library-attached sounds, be careful: embedding long audio increases SWF size and may behave differently with streaming vs event sync.
  • If audio still cuts when changing frames, confirm that no other frame script reinitializes or replaces _root.narrationController.

This keeps control logic central, avoids the frame-hack, and makes it trivial to add pause/resume, progress display, or an on-complete handler later. Note: modern browsers no longer support Flash natively; if this project must run today, consider migrating audio to an HTML5/JS solution.

Recommended Answers

All 2 Replies

Member Avatar for Member #114696

Giving you an idea how to do it. Try it, if encounter any problem post here with your AS. Create a new layer in root. Don't insert any frame except the first. Select the only and the first frame and goto to action panel. Create a sound object.

Now, every button will use same sound object. So no overlapping.

Or if you dont want a common one, just use

Vishesh,
Thanks for this answer.
Fortunately, I figured a way around it. It's a little different than what you suggest, but, I will try yours later on.

Here's how I finally accomplished what I needed.

Each frame, is now actually 3 frames long.

I set it up as follows.
Frame 1 has a "stop movie" script.
Frame 2 has a "stop all sound"
Frame 3, has the sound in the frame.
The button says "go to and play frame 2".
This way, frame 2 tells all the sound to stop but playing on to frame 3, the new sound starts.

Doing it this way is obviously a long way around, but, it worked. I'm too tired to change it now. LOL. But, I'll try your suggestion tomorrow.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.