Highlighted

Several buttons in a frame (html5 canvas)

New Here ,
Nov 28, 2019

Copy link to clipboard

Copied

Hi !

I am a beginner in Animate I would like to have several buttons (with different target in a frame on my animation (HTML5 canvas), but I can only operate one.
I put the following code on my "Actions" timeline :
"This.stop ();
this.buttonname1_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame.bind (this));
function fl_ClickToGoToAndPlayFromFrame ()
{this.gotoAndPlay ( "target1");} "

 

this.buttonname2_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame.bind (this));
function fl_ClickToGoToAndPlayFromFrame ()
{this.gotoAndPlay ( "target2");} ".

 

this.buttonname3_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame.bind (this));
function fl_ClickToGoToAndPlayFromFrame ()
{this.gotoAndPlay ( "target3");} ".

 

The first button works well, but not the others 😕

So, my question : what is the right code for having several buttons ?

Thanks a lot !

 

JLS

TOPICS
Code, Timeline

Views

97

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

Several buttons in a frame (html5 canvas)

New Here ,
Nov 28, 2019

Copy link to clipboard

Copied

Hi !

I am a beginner in Animate I would like to have several buttons (with different target in a frame on my animation (HTML5 canvas), but I can only operate one.
I put the following code on my "Actions" timeline :
"This.stop ();
this.buttonname1_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame.bind (this));
function fl_ClickToGoToAndPlayFromFrame ()
{this.gotoAndPlay ( "target1");} "

 

this.buttonname2_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame.bind (this));
function fl_ClickToGoToAndPlayFromFrame ()
{this.gotoAndPlay ( "target2");} ".

 

this.buttonname3_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame.bind (this));
function fl_ClickToGoToAndPlayFromFrame ()
{this.gotoAndPlay ( "target3");} ".

 

The first button works well, but not the others 😕

So, my question : what is the right code for having several buttons ?

Thanks a lot !

 

JLS

TOPICS
Code, Timeline

Views

98

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
Nov 28, 2019 0
Adobe Community Professional ,
Nov 28, 2019

Copy link to clipboard

Copied

You gave each click handler function the exact same name. How do you think it's supposed to tell which is which if you do that?

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 28, 2019 0
GoryGreg LATEST
Engaged ,
Nov 29, 2019

Copy link to clipboard

Copied

As Clay mentioned you have given each function the same name. You need to have each function named differently.

 

Try this (I have bolded and turned text to red to show what I added)...

 

this.stop ();
this.buttonname1_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame1.bind (this));
function fl_ClickToGoToAndPlayFromFrame1 ()
{this.gotoAndPlay("target1");} 

 

this.buttonname2_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame2.bind (this));
function fl_ClickToGoToAndPlayFromFrame2 ()
{this.gotoAndPlay("target2");} 

 

this.buttonname3_btn.addEventListener ("click", fl_ClickToGoToAndPlayFromFrame3.bind (this));
function fl_ClickToGoToAndPlayFromFrame3 ()
{this.gotoAndPlay("target3");}

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 29, 2019 0