« Thinking out loud...flash | Main | neuro sim -- sneak peak »

global from a movieclip timeline

Most of my flash work lives in the first frame. But today, I'm working with a movieclip's timeline. I kept trying to change the value of a global variable, declared on the main timeline, from the last frame of my movieclip. No luck.

Then I referenced the variable as _root.variable. Eureka!


Was it originally declared as _global? That's odd. I have had some weird experiences with _global as well.

Yep, it's declared as a global in one of the first lines of code on the first frame on the main timeline.

It was really weird. I tried adding _root, just to see if anything would happen. In this case, I was thinking about how I could "escape" from a moveclip, like I would if it was a function.

I had never had that problem, if a variable was declared as _global, I was always able to change it using _global.thatVariable = "anotherValue"; which means I can always access that by just thatVariable.