You're not resetting "rect" to a new sprite on each loop

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Deniz Davutoglu
Sent: Tuesday, June 10, 2008 6:46 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Catching target Name

 

Hello I use the following code and I try to catch the name of object
that I clicked. With code I use below everytime it gives me
"instance1" do you have any idea how can I do this.

StageAlign.TOP_LEFT
import flash.display.Sprite;
import flash.events.MouseEvent;
var kareler:Array= new Array()
var rect:Sprite = new Sprite();
var xxx:Boolean
var color:String
var mainRect:Sprite = new Sprite();
mainRect.graphics.beginFill(0x000000);
mainRect.graphics.drawRect(-3, -3, 456,456);
for (var i:uint=0;i<=8;i++){
for (var j:uint=0;j<=8;j++){
kareler[i]=rect
if(xxx){
xxx=false
color="0xCCCCFF"
}
else {
xxx=true
color="0x663300"

}
kareler[i].graphics.beginFill(color);
kareler[i].graphics.drawRect(j*50, i*50, 50,50);
kareler[i].buttonMode = true;
kareler[i].addEventListener(MouseEvent.CLICK, clicked);
mainRect.addChild(kareler[i]);
}

}

addChild(mainRect)

function clicked(event:MouseEvent):void {
trace(event.target.name);
}

 

Reply via email to