Skip navigation
mgjacob117
Currently Being Moderated

Sound continues to play after leaving movieclip

Jun 26, 2012 6:23 AM

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!

 
Replies
  • Currently Being Moderated
    Jun 26, 2012 7:42 AM   in reply to mgjacob117

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 8:53 AM   in reply to mgjacob117

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 9:22 AM   in reply to mgjacob117

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 11:10 AM   in reply to mgjacob117

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points