A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: can not stop an mp3

  1. #1
    Member
    Join Date
    Feb 2010
    Posts
    40

    can not stop an mp3

    this compiles fine--and plays and loops "game1loop"--the loop stops when
    "BtnStopSoundGOne" is pushed - but I want the mp3 to stop right away, not at the end of the file--I really do not think the "mySndCh.stop();" works here I think the loop stops when "loopsound = 0"
    help!!!! I need the music to stop right away
    sorry if the code is sloppy I am a noob


    code:
    var loopsound:Number;
    var gameonesound:Sound = new game1loop();
    var mySndCh:SoundChannel;


    btnDrawGame.addEventListener(MouseEvent.MOUSE_DOWN ,btnDrawGameClick);
    function btnDrawGameClick(e:MouseEvent):void {
    if (btnLockOut == 0)
    {
    playMusic();
    loopsound = 1;
    //fscommand("exec","drawingSketchbig.exe");
    }
    }
    function playMusic():void
    {
    trace("playMusic called");
    gameonesound.play();
    mySndCh = gameonesound.play();
    mySndCh.addEventListener(Event.SOUND_COMPLETE, loopMusic);
    }
    function loopMusic(e:Event):void
    {
    if (loopsound == 1)
    {
    mySndCh.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
    playMusic();
    }
    }
    BtnStopSoundGOne.addEventListener(MouseEvent.MOUSE _DOWN,BtnStopSoundGOneClick);
    function BtnStopSoundGOneClick(e:Event):void
    {
    trace("stopsound called");
    mySndCh.stop();
    loopsound = 0;

    }

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    May be add this line in the BtnStopSoundGOneClick function

    mySndCh.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Feb 2010
    Posts
    40
    Quote Originally Posted by cancerinform View Post
    May be add this line in the BtnStopSoundGOneClick function

    mySndCh.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
    tried it --same prob
    the thing is I do not want to wait till the sound is complete
    if the mySndChn.stop was working wouldn't it stop right away?

  4. #4
    Member
    Join Date
    Feb 2010
    Posts
    40
    any ideas? bump

  5. #5
    Member
    Join Date
    Feb 2010
    Posts
    40

    resolved

    I put this in and it will stop the mp3

    SoundMixer.stopAll();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center