ericaalicen
Programmer
I'm having an issue looping through and accessing variable names dynamically in actionscript.
This code to call one directly works.
When I put the code in the loop and try to make it work for square1-square5, it doesn't work.
Can anyone tell me what I'm doing wrong?
This code to call one directly works.
Code:
mcSquares.square1.onRollOver = function(): Void {
mcSquares.square1._visible = false;
};
When I put the code in the loop and try to make it work for square1-square5, it doesn't work.
Code:
var nSquares:Number = 6;
for(var i:Number = 1; i < nSquares; i++)
{
trace(mcSquares.square[i]);
mcSquares.square[i].onRollOver = function(): Void {
mcSquares.square[i]._visible = false;
};
}
Can anyone tell me what I'm doing wrong?