• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

play and stop movieclip with button

Community Beginner ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

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();
}

 

Views

299

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

Why are you trying to tell a function to play?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

i thought, that i call it with the name and inside is the movieclip...

obviousley this is wrong

the movieclips name is rot_anim

that it stops at the end of the timeline is the function rot_animation

 

can you please tell me, how i have to write it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

You just call the function, like all functions are called in ActionScript.

 

Not sure why you're using AS3 though. I assume this isn't a project intended for web use.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

LATEST

no it is not for web

i have a problem calling the function because i do not know the synthax for it.

several times i asked in this forum, where i could learn as3. i never got an answer on this question. it seems to be some secret knowledge?

maybe you help me to write it properly? that would be nice ;o)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines