Problem getting object instance name from event

This is a discussion on Problem getting object instance name from event within the Macromedia Flash forums in Adobe Tools category; If I use the following example code : function test():void { var img:Image = new Image; img.name = "Tree"; img.source = "tree.jpg"; theCanvas.addChild(img); img.addEventListener(MouseEvent.CLICK, moveImage); } private function moveImage(event:MouseEvent):void { trace(event.target.name); } the trace output returns something like "FlexLoader9" instead of "Tree" when I click on the image. Any suggestions on how I can retrieve the object instance name in the event routine? (The above code SHOULD work according to the online docs)....

Go Back   Application Development Forum > Adobe Tools > Macromedia Flash

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 11-11-2008, 01:52 PM
camden_kid
Guest
 
Default Problem getting object instance name from event

If I use the following example code :

function test():void
{
var img:Image = new Image;
img.name = "Tree";
img.source = "tree.jpg";
theCanvas.addChild(img);
img.addEventListener(MouseEvent.CLICK, moveImage);
}

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

the trace output returns something like "FlexLoader9" instead of "Tree" when I
click on the image.

Any suggestions on how I can retrieve the object instance name in the event
routine? (The above code SHOULD work according to the online docs).

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:03 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.