-
[RESOLVED] addEventListener(MouseEvent.MOUSE_DOWN, myFunction)
hi
i am making drag drop game.i create some movie clips dynamic.
this is the code::
recipesArray=["Steak","Chicken Panee","Bread","Fava Beans", "Jam"];
/////Create Movieclips && set their text
var mcArray:Array =new Array();
for (var i:int=0; i<recipesArray.length; i++) {
var mc:MovieClip = new MovieClip();
mc.name = "mc" + i;
mc.graphics.beginFill(0xFFE1C4);
mc.graphics.drawRect( 0, 0, 150, 25 );
mc.graphics.endFill();
mc.x = recipeBox_mc.x + 25;
mc.y = recipeBox_mc.y + 20+ (50*i);
var t:TextField = new TextField();
t.text = recipesArray[i];
var tf:TextFormat = new TextFormat();
tf.color = 0x000000;
tf.size = 10;
tf.font = "Arial";
t.setTextFormat(tf);
mc.addChildAt(t, 0);
addChild(mc);
mcArray[i] = mc;
stage.addChild(mc);
mcArray[i].alpha=.5;
mcArray[i].mouseChildren = false;
mcArray[i].buttonMode = true;
mcArray[i].addEventListener(MouseEvent.MOUSE_DOWN, createInstant);
now i want to know which movie clip is clicked .HOW????
thanks in advance
-
You can reference it in the createInstant function as e.target, "e" being the MouseEvent parameter.
-
Hi
You can get the current clicked movie reference with evt.currentTarget as given below
function createInstant(evt:Event):void {
trace(evt.currentTarget)
}
B.S www.flashankaractive.com | http://actionscript.flashankaractive.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|