9 Replies Latest reply: May 19, 2013 7:25 AM by hholdsworth RSS

    Problem with Play Pause AS3 button on main timeline

    Alex_Cissokho

      Wondered if anyone can help with this? Have been trying to create a play/pause button for the main timeline in my flash movie.

       

      Created a movie clip with 1st frame - a pause graphic, then on 2nd frame - play graphic, labelled the frames 'pause' and 'play' consecutively and put a stop action on the first frame of the movieclip.

       

      Then put the following code in the actions layer of the main timeline (and gave instance name of 'ppBtn' to the movieclip):

       

      var pp:Boolean = true;


      function ppState(event:MouseEvent) {

      if(pp) {

      stop();

      event.target.gotoAndStop('pause');

      pp = false;

      }else{

      play();

      event.target.gotoAndStop('play');

      pp = true;

      }

      }

      ppBtn.addEventListener(MouseEvent.CLICK, ppState);

       

      It works in stopping and starting the movie but the actual movieclip doesn't toggle between the pause and the play graphics (just stays on the 'pause' state - 1st frame). Any help on this much appreciated!

       

      thanks