i created a class for my game and i've been having problems
accessing my variables. i know its a scope problem(i think) so can
anyone just point it out for me? i have been stumped for teh past
hour on this so i figured i'll just ask for a little help.
the problem is i cant get the fourLetters array. What this
program does is create a jumbled word which falls down the screen.
when you type the answer correctly, another word appears etc.
problem is, when i call creatword again and input
parentObj.fourLetters or parentObj.getCurrentList() as a parameter,
it says it is undefined. it worked the first time but why not the
second time? what happens to my array during this time?
In gerneral avoid using _root and always test the this
property with a trace to make sure it is correct.
I think it would help the answer if you included the timeline
code too so it is possible to see how the Array is called.
>>it worked the first time but why not the second time?
Most likely you are using instance properties (fourLetters,
fiveLetters) to save the LoadVars data. Then you create a new
instance but do not load the data again assuming it's already
there. And when you are using instance properties, it's not. The
properties fourLetters and fiveLetters are defined per instance. A
way to solve this is by using class properties making the content
static for all instances of the class.
private static var fourLetters:Array;
private static var fiveLetters:Array;