• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Engaged ,
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

151

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

Community Expert , 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

Votes

Translate

Translate
Community Expert ,
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

Votes

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
Engaged ,
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

Votes

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
Community Expert ,
Feb 18, 2022 Feb 18, 2022

Copy link to clipboard

Copied

LATEST

Awesome!

 

You're welcome!

Votes

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