• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Sound continues to play after leaving movieclip

New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

I have some sound loaded with AS3 in the first frame of the mc(s):

var mySound:Sound = new Sound();

var myChannel:SoundChannel = new SoundChannel();

var lastPosition:Number = 0;

mySound.load(new URLRequest("narration/43_Pres.mp3"));

myChannel = mySound.play();

when you click the home btn to go back to the main menu the narration stops,

Home_btn1.addEventListener(MouseEvent.CLICK,getMainMenu);

function getMainMenu(evt:MouseEvent):void {stop(); SoundMixer.stopAll(); gotoAndStop(2);}

but the sounds that are loaded in later frames keep playing

var mySound2:Sound = new Sound();

var myChannel2:SoundChannel = new SoundChannel();

mySound2.load(new URLRequest("narration/CLICK.mp3"));

myChannel2 = mySound2.play();

I tried adding the main part of the above to the first frame and just the last line to the frame that needs the clicks, but that still did not work.

I'm a novice at this and it's driving me crazy that I can't fix the problem. HELP!

TOPICS
ActionScript

Views

895

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

Try using myChannel.stop(); and myChannel2.stop(); before you leave the frames.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

Part of the problem (I guess) is that the Home btn is at the root level whereas the mc with the clicks is second level with the code being on the timeline. So if I try to put the myChannel2.stop(); in the btn code I get an Access if undefined property error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

It is not clear where your code is based on what you just wrote, but if you need to talk to a parent timeline you can target it using Movie(parent), as in...  MovieClip(parent).myChannel2.stop();

Another way would be to assign an event listener to that movieclip from the main timeline for a custom event and have that movieclip dispatch the custom event when you want to call the function in the main timeline to stop the sound.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

The program I am building is a demo of a software program we make, so it basically says "go here...click this...go there...click that." I have a main menu that has 8 btns that go to sections(mc's) with 2 to 12 subsections (each are mc's as well) The home btns that returns you to the MM are at the root level because I don't know how to word the code so go from inside a mc to the root level, and I'm thinking that might be my best solution because when the Home btn is chosen is when the "clicks" keep playing but the narration stops. They don't play going between subsections or when I pause.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

Try:   " MovieClip(root) "   to target the root timeline

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

Thank you!! That did the trick.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines