Highlighted

Creating a "Play Button" in Adobe Animate Actionscript 3.0?

New Here ,
Jul 25, 2018

Copy link to clipboard

Copied

Hello!

I have a project for school where I have to create an animation with audio. I have that finished, but my teacher recommended that I make a playbutton for my animation.

I have tried to follow numerous tutorials but the majority of them are outdated and I get errors when I try to follow them.

What I want to achieve is a button that I press that starts the animation and then disappears.

I already have the button in place but I can't figure out what code to put.

Thanks

Adobe Community Professional
Correct answer by Colin Holgate | Adobe Community Professional

If you select the button and in Properties give it a name, say 'startBtn', this code would do what you need (the code would be in the frame where the button is, most likely frame 1):

stop();

startBtn.addEventListener(MouseEvent.CLICK,dostart);

function dostart(e:MouseEvent){

  startBtn.removeEventListener(MouseEvent.CLICK,dostart);

  play();

}

To make the button go away you would put a blank keyframe in the same layer as the button, in frame 2 for example. At the end of the animation you might want to jump back to the start again, which you could do with:

gotoAndStop(1);

TOPICS
ActionScript

Views

754

Likes

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

Creating a "Play Button" in Adobe Animate Actionscript 3.0?

New Here ,
Jul 25, 2018

Copy link to clipboard

Copied

Hello!

I have a project for school where I have to create an animation with audio. I have that finished, but my teacher recommended that I make a playbutton for my animation.

I have tried to follow numerous tutorials but the majority of them are outdated and I get errors when I try to follow them.

What I want to achieve is a button that I press that starts the animation and then disappears.

I already have the button in place but I can't figure out what code to put.

Thanks

Adobe Community Professional
Correct answer by Colin Holgate | Adobe Community Professional

If you select the button and in Properties give it a name, say 'startBtn', this code would do what you need (the code would be in the frame where the button is, most likely frame 1):

stop();

startBtn.addEventListener(MouseEvent.CLICK,dostart);

function dostart(e:MouseEvent){

  startBtn.removeEventListener(MouseEvent.CLICK,dostart);

  play();

}

To make the button go away you would put a blank keyframe in the same layer as the button, in frame 2 for example. At the end of the animation you might want to jump back to the start again, which you could do with:

gotoAndStop(1);

TOPICS
ActionScript

Views

755

Likes

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
Jul 25, 2018 0
Adobe Community Professional ,
Jul 25, 2018

Copy link to clipboard

Copied

If you select the button and in Properties give it a name, say 'startBtn', this code would do what you need (the code would be in the frame where the button is, most likely frame 1):

stop();

startBtn.addEventListener(MouseEvent.CLICK,dostart);

function dostart(e:MouseEvent){

  startBtn.removeEventListener(MouseEvent.CLICK,dostart);

  play();

}

To make the button go away you would put a blank keyframe in the same layer as the button, in frame 2 for example. At the end of the animation you might want to jump back to the start again, which you could do with:

gotoAndStop(1);

Likes

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
Reply
Loading...
Jul 25, 2018 0
New Here ,
Jul 25, 2018

Copy link to clipboard

Copied

Hello-

thank you for the help!

when i try to test the animation i get this error on line 3 and 9;

1120: Access of undefined property startBtn

Likes

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
Reply
Loading...
Jul 25, 2018 0
New Here ,
Jul 25, 2018

Copy link to clipboard

Copied

Edit: I redid everything to do with the button and tried again, I no longer get the error, and so I have no idea what happened in the first place. It works now!

Thank you so much for your help~!!

Likes

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
Reply
Loading...
Jul 25, 2018 0
Adobe Community Professional ,
Jul 25, 2018

Copy link to clipboard

Copied

Glad you figured it out!

Likes

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
Reply
Loading...
Jul 25, 2018 0
New Here ,
Nov 26, 2019

Copy link to clipboard

Copied

Hello, Colin,

 

How can I play audio and animation after click the play btn ????

Because I can play and audio and animation in the same time in Chrome(It's not allow auto play).

Thank you so much.

 

Charis

 

Likes

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
Reply
Loading...
Nov 26, 2019 0
New Here ,
Nov 27, 2019

Copy link to clipboard

Copied

Sample : http://brown.perfectlink.com.hk/citb_ecard/view_card.php?card_id=2112

 

It is Actionscript 3.0 or html5 ????

Likes

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
Reply
Loading...
Nov 27, 2019 0