I want to trace the name of the point the mouse is over… But it keeps tracing: Target19…?
What am I doing wrong? Why can’t it trace the name of array object?
var bWidth:Number = stage.stageWidth;
var bHeight:Number = stage.stageHeight;
var grid:Number = 20; // Size of the grid and number of lattice points in each direction
var dotsWide:Number = Math.ceil(bWidth/grid) - 1;
var dotsHigh:Number = Math.ceil(bHeight/grid) - 1;
var board:Sprite = new Sprite();
var shape1:MovieClip = new MovieClip();
addChild(shape1);
stage.addChild(board);
var hitArray:Array = new Array();
for (var k:int = 0; k < 20; k++) {
hitArray[k] = new MovieClip();
hitArray[k].name = "target" + k;
addChild(hitArray[k]);
for (var i=1; i<=dotsHigh; i++) {
for (var j=1; j<=dotsWide; j++) {
hitArray[k].graphics.beginFill(0x333333,1);
hitArray[k].graphics.drawRect(j*grid,i*grid,3,3);
hitArray[k].graphics.endFill();
}
}
}
for (var m:int=0; m<hitArray.length; m++) {
hitArray[m].addEventListener(MouseEvent.MOUSE_OVER, glow);
function glow(e:MouseEvent):void {
trace(e.target.name );
}
}