13 Replies Latest reply: Nov 14, 2011 11:10 AM by Peter Celuch RSS

    Stop sound when object stops animating at end of stage

    EGBAR.Mary Community Member

      Hi,

       

      I am trying to make the sleigh bell sound stop when my object(santa) reaches the end of stage. First of all, I don't exacly know how to write an if statement, second I get an error when I try to stop the sound. Can anyone help, please? Thank you!

       

      var mySound:Sound = new bellsSound();

      mySound.play();

       

      var myTween:Tween = new Tween(santa, "x", Regular.easeOut, -100, 810, 25, true);

      addChild(santa);

       

       

      function stopSound(event:Event):void

                {

                          mySound.stop();

                }

       

       

      if(santa.x = 800);

          else if(santa.x = 0) {

              addEventListener(Event.ENTER_FRAME,stopSound);

                          trace("reached end");

          }