Skip to main content
Participating Frequently
September 12, 2022
Question

is repeatitive function name of buttons prones to problems? (html5)

  • September 12, 2022
  • 1 reply
  • 1208 views

hi everyone, im pretty new to animate. im trying to make an interactive animation with mainly navigation buttons, and i do this by using gotoandplay/stop codes in code snippets a lot. the first few buttons worked really well, but the problem is the codes seem just not take effects on the new buttons i've created recently (the old ones still work). 

 

here's one of the many codes that failed to work:

 

this.mlh1_navigation.addEventListener("click", fl_ClickToGoToAndPlayFromFrame_28.bind(this));

function fl_ClickToGoToAndPlayFromFrame_28()
{
this.gotoAndPlay(19);
}

 

i've searched in the community and i found a post similar to my situation, to which an answer suggested having different function names for the buttons, for repeatitive function name is problematic. im not really sure how to change function name? i do keep the frame number in the second line different though i dont know what does it mean...

 

anyone knows what is going on here? 

 

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
September 12, 2022

the wizard should be changing the function names.  

 

but, if you really have more than one fl_ClickToGoToAndPlayFromFrame_28(), then yes, it's a problem.  never use the same function name more than once. 

 

to change a name, just change it in the listener(s) and the function iteself:

 

this.mlh1_navigation.addEventListener("click", whatever.bind(this));

function whatever()
{
this.gotoAndPlay(19);
}

4736leahAuthor
Participating Frequently
September 12, 2022

hello kglad, thank you very much for replying to the post!😭 but i just tried both wizard (go to frame number and play-this timeline-changed the frame number to 19 manually-next-on mouse click-mlh1_navigation) and your code (just copied and pasted it to the corresponding frame on the action layer), and it still does not work... I am seriously considering starting all over again.....😭

kglad
Community Expert
Community Expert
September 12, 2022

open your browser's developer console and start debugging your app.  if you don't know how to use the console, open it when you test.  do whatever you need to do to trigger the first error and note what appears in the console.

 

copy and paste that into this forum.