I am simply trying to do one of those "match-2" games. I just started doing it, and since I am a beginner, I am trying to understand how Arrays work. Therefore I wrote this simple program:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
var Ar:Array = [];
Ar[0] = A;
Ar[1] = B;
Ar[2] = C;
public function Main()
{
for( var i = 0; i < 3; i++ )
{
Ar.buttonMode = true;
Ar[i].addEventListener( MouseEvent.MOUSE_OVER, MouseOverAct );
Ar[i].addEventListener( MouseEvent.MOUSE_OUT, MouseOutAct );
}
}
public function MouseOverAct( mouseEvent:MouseEvent ):void
{
mouseEvent.target.alpha = 0.1;
}
public function MouseOutAct( mouseEvent:MouseEvent ):void
{
mouseEvent.target.alpha = 1.0;
}
}
}
However, after declaring the array and trying to put the MovieClips (which are already on the stage, with instance names A, B, C) inside it I get an "Undefined property" error. I have tried to correct it using Ar.push(), but it doesn't work as well. Can someone help me?