Global var using in Flash MX

Hi!

I’m trying to set global var at the main movie timeline in first frame. Than I need to reach and to change this var inside of the sub-mc every time when it plays in loop with main mc.

In details: there is a sub-sub-mc which gets visibility from sub-mc depending on this global var, and also changes this global var. So I need to reach it and change every loop of mc.

Would be very glad to get any suggestions. I tryed many ways - nothing has worked.

oleg. :frowning:

refer to your variable as _root.variablename that will target a variable located on the main timeline.

Thx!

But how to declare the var?

var a = 0;
_global.a = 0;

and where?

oleg.

_root.a = 0;

this would be for a variable named a at the root timeline which is global.

At least concearning the flash 5 version(don´t now if it changed in FMX):

Global variables are variables that can be set or retrieved at any point anywere. What you are sugesting is just a variable located a the root, then, a local variable located at the root (or main timeline) not global.
Global variables don´t exist on flash they are simulated by this code:

Object.prototype.yourGlobalVariable = value;

But it is easier if you refer to a variable to the respective location .

Example: You want to set the value of the pamelaAndersonIsHot variable located inside the movieclip foxy at the main timeline (_root) to true:

_root.foxy.pamelaAndersonIsHot = true;

:stuck_out_tongue:

=)