Copy link to clipboard
Copied
Hi Animate Support,
I'm using JavaScript in Canvas and I am trying to find a way to call a function on a movie clip on the main timeline from a movie clip in a nested timeline. This is important because of the way the graphics work in my FLA. Here's my code on the main timeline:
let bellFrontLt = this.bellFrontLt_mc;
function positionBellFrontLt()
{
bellFrontLt.x = 200;
bellFrontLt.y = 100;
alert("move bell flower")
}
The name of the nested movie clip is all_clip which holds the movie clip (functioning as a button), bellFrontLt_btn. Neither of the commented-out commands below worked. Here's my code on the nested clip:
this.bellFrontLt_btn.addEventListener("click", callFunctionMainTimeline.bind(this));
function callFunctionMainTimeline()
{
//this.parent.positionBellFrontLt();
//exportRoot.positionBellFrontLt();
}
Any help finding a way to do this will be greatly appreciated.
Zaffer
Hi.
You need to make the positionBellFrontLt function a method of the main timeline for being able to call it from another frame or timeline.
Like this:
this.positionBellFrontLt = function()
{
bellFrontLt.x = 200;
bellFrontLt.y = 100;
alert("move bell flower")
};
Then call it using:
exportRoot.positionBellFrontLt();
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Hi.
You need to make the positionBellFrontLt function a method of the main timeline for being able to call it from another frame or timeline.
Like this:
this.positionBellFrontLt = function()
{
bellFrontLt.x = 200;
bellFrontLt.y = 100;
alert("move bell flower")
};
Then call it using:
exportRoot.positionBellFrontLt();
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Thanks so much João!
Your answer works perfectly. You saved me from going crazy 🙂
Zaffer
Copy link to clipboard
Copied
Awesome!
You're welcome!