flash script help

  • Started
  • Last post
  • 3 Responses
  • ridg0026

    hopefully this will make sense to someone, bear with me. I'm building a FLASH site with a lengthy animation on the main timeline. I would like to have it so that when the mouse is moved on the stage, the play/pause button appears (allowing for the playing/pausing of the main timeline).

    my code for that piece (which is working fine):
    stop()
    btn_playhead_invisible.addEventL... showbutton)
    function showbutton(myevent:MouseEvent):v... {
    gotoAndPlay("showbutton");
    }

    the problem im having is that I cannot get Flash to recall the state of the play/pause button when the mouse event above re-occurs. I know its because my code calls the movieclip at frame 1 but I dont know how to fix it so that FLASH remembers whether the button was in the pause state or play state.
    my code for the play/pause:
    stop()
    btn_pause.addEventListener(Mouse... pausemain);
    function pausemain(myevent:MouseEvent):vo... {
    MovieClip(root).stop();
    }

    btn_pause.addEventListener(Mouse... showbuttonplay);
    function showbuttonplay(myevent:MouseEven... {
    gotoAndStop("play");
    }

    btn_pause.addEventListener(Mouse... pausemovie);
    function pausemovie(myevent:MouseEvent):v... {
    gotoAndStop("pause");
    }

    anyone?

  • uan0

    use a boolean variable to store the actual playstate. when you show your button, check the var to decide to jump to 'play' or 'pause' and update the boolean...

  • ifeltdave0

    to expand on uan:

    var myPlayState:Boolean = true;

    On button click:

    if (myPlayState == true) { pause the movie } else { play the movie }

    • also on button click:
      myPlayState = !myPlayState
      just flips it to the opposite
      ifeltdave
  • ridg00260

    thanks guys...very helpful