how to call a function on the main timeline from a nested timeline

Contributor ,
Feb 17, 2022 Feb 17, 2022

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

TOPICS
Code , How to , Timeline

Views

62

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Feb 17, 2022 Feb 17, 2022
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

Likes

Translate

Translate
Adobe Community Professional ,
Feb 17, 2022 Feb 17, 2022

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

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
community guidelines
Contributor ,
Feb 17, 2022 Feb 17, 2022

Copy link to clipboard

Copied

Thanks so much João!

Your answer works perfectly.  You saved me from going crazy 🙂

Zaffer

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
community guidelines
Adobe Community Professional ,
Feb 18, 2022 Feb 18, 2022

Copy link to clipboard

Copied

LATEST

Awesome!

 

You're welcome!

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
community guidelines