Skip to main content
Known Participant
September 18, 2020
Question

play and stop movieclip with button

  • September 18, 2020
  • 1 reply
  • 554 views

i want to play an mc from frame 1 to frame 20 - so far so good - here ist the script

rot_anim.stop();
function rot_animation (evt:MouseEvent) {
    rot_anim.gotoAndPlay(1);
    rot_anim.addEventListener(Event.ENTER_FRAME,fStop);
}
function fStop(evt:Event)
{
    if (rot_anim.currentFrame>19) { 
       rot_anim.stop();
       rot_anim.removeEventListener(Event.ENTER_FRAME,fStop);
    }
}
rot_anim.addEventListener(MouseEvent.CLICK, rot_animation);

now i would like to start to play the mc with a click on a button - but that does not work and i do not know what i am doing wrong. can anybody help me?

here is the script for the button calling the function

button1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
	rot_animation.play();
}

 

    This topic has been closed for replies.

    1 reply

    Legend
    September 18, 2020

    Why are you trying to tell a function to play?

    Known Participant
    September 21, 2020

    i thougt i have to, because in it there are the comands that rot_anim has, after the comand play, to stop at frame 19 - is that wrong?

    if i say rot_anim.play(); it starts playing after i click on the button, but it does not stop animore... it plays over and over and over...

    how else do i have to write it then?

    Legend
    September 22, 2020

    You understand that functions aren't movieclips, yes? Functions don't have timelines. You don't "play" a function, you just call it.