Copy link to clipboard
Copied
I have made a function that resets Movie Clips:
function reset_TXT(){
this.txtScroll_PF.gotoAndPlay(0);
this.txtScroll_MD.gotoAndPlay(0);
}
When a frame is accessed, the function is fired:
reset_TXT();
I get this odd error:
Frame 1? Frame 1 has no reference to this function at all!
It is Defined in Frame 2:
It is Called in Frame 2 and all subsequent frames after:
So, my function is indeed Defined, so why do I get this error, too?
Calling it this way only produces a different error:
this.reset_TXT();
Uncaught TypeError: this.reset_TXT is not a function
Can anyone explain this madness?
Thanks!
Hi.
If you console.log the 'this' keyword inside of that function you'll see that it refers to the Window object.
One way of solving this issue is to store a reference to the current timeline first. Like this:
var that = this;
function reset_TXT()
{
that.txtScroll_PF.gotoAndStop(0);
that.txtScroll_MD.gotoAndStop(0);
}
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Hi.
If you console.log the 'this' keyword inside of that function you'll see that it refers to the Window object.
One way of solving this issue is to store a reference to the current timeline first. Like this:
var that = this;
function reset_TXT()
{
that.txtScroll_PF.gotoAndStop(0);
that.txtScroll_MD.gotoAndStop(0);
}
I hope this helps.
Regards,
JC
Find more inspiration, events, and resources on the new Adobe Community
Explore Now