Skip to main content
Inspiring
April 25, 2023
Answered

Access root variable from object in Adobe Animate

  • April 25, 2023
  • 1 reply
  • 971 views

In Adobe Animate, using the HTML5 canvas, I've created a boolean variable at the root level called var_grandparents. I've now created a movie clip. When the movie clip gets to a certain frame, it's supposed to reference the variable and, if the variable is true, start another movie clip playing, but I can't get it to see it. I just keep getting 'undefined'.

I've tried

alert(this.parent.var_grandparents)

 and

alert(Object.var_grandparents)

but I just get 'undefined'. Is there a way to reference it, please?

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

The boolean you're trying to access must be a property of the root and not a variable. For example:

// code in the root
this.yourBoolean = true; // not var yourBoolean = true;

// code in the child Movie Clip
alert(this.parent.yourBoolean); // or exportRoot.yourBoolean

 

Please notice that exportRoot is a global variable that stores a reference to the root created by Animate automatically.

 

I hope this helps.

 

Regards,

JC

1 reply

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
April 25, 2023

Hi.

 

The boolean you're trying to access must be a property of the root and not a variable. For example:

// code in the root
this.yourBoolean = true; // not var yourBoolean = true;

// code in the child Movie Clip
alert(this.parent.yourBoolean); // or exportRoot.yourBoolean

 

Please notice that exportRoot is a global variable that stores a reference to the root created by Animate automatically.

 

I hope this helps.

 

Regards,

JC

Inspiring
April 25, 2023

I can't believe it was that simple! I thought I had to declare the booleans with 'let'. Thanks!

JoãoCésar17023019
Community Expert
Community Expert
April 25, 2023

You're welcome!