View Full Version : "this" identifier not working with global vars
JimRowan
12-05-2008, 01:16 PM
So normally I would say the "this" identifier is quite powerful, but I'm having trouble figuring out how to use it with an instance that has a dot identifier. For instance:
this["myGlobal.myVariable"]++;
does nothing. It doesn't like that "dot" in the middle. Any way around this?
CyanBlue
12-05-2008, 01:26 PM
Howdy and Welcome... :)
I can only answer how you can avoid that dot problem, but I am not sure that solves your scope problem if there is any...
You simply use another array notation whenever you see dot... As simple as that... ;)
this["myGlobal"]["myVariable"]++;
wvxvw
12-05-2008, 01:28 PM
First, there're no global variables in AS3, likewise there's no global object where you can put them. From your code it seems that you're trying to access a static class member, so, it should be: myGlobal["myVariableName"]++ where myVariableName is the name of the variable or expression that evaluates to that variable name.
JimRowan
12-05-2008, 01:34 PM
First, there're no global variables in AS3, likewise there's no global object where you can put them. From your code it seems that you're trying to access a static class member, so, it should be: myGlobal["myVariableName"]++ where myVariableName is the name of the variable or expression that evaluates to that variable name.
Yup, static class member is what I literally meant, and your code worked like a charm. I appreciate that so much, bud. You have yourself a good weekend!
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.