Copy link to clipboard
Copied
Hello all thanks for your time
I have a problem calling a timeline action inside a function, the movie clip i use in the function always comes out as undifined.
but when i call the action from within a button function it works as normal.
function reset() {
this.rhpump_mc.gotoAndStop(0);
console.log(2)
this.lhpump_mc.gotoAndPlay(51);
}
then i have a button
this.stop_btn.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler(e)
{
console.log(2)
reset()
}
console comes up with both movie clips undefined
but if i put the code all within the button like this .
this.stop_btn.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler(e)
{
this.rhpump_mc.gotoAndStop(0);
console.log(2)
this.lhpump_mc.gotoAndPlay(51);
}
I get no errors and it all functions normally
I must be doing something wrong .
Thank you for your help
PETER
use reset.bind(this)() to call reset
Copy link to clipboard
Copied
use reset.bind(this)() to call reset
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
you're welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
I understand I did make another posting before that explaining why I realise now after some research
that the "this" is not recognized inside the function when it was called as the "this " only has meaning to the object when it is binded ,but looks like it wasnt posted sorry about that.
Brg
Peter
Find more inspiration, events, and resources on the new Adobe Community
Explore Now