[flexcoders] Re: Getting error when trying to get id of label when adding evt listener

2008-07-23 Thread Michael VanDaniker
You want to look at the event's currentTarget instead of target.

From the documentation for MouseEvent:

target = The InteractiveObject instance under the pointing device. The
target is not always the object in the display list that registered
the event listener. Use the currentTarget property to access the
object in the display list that is currently processing the event.

--- In flexcoders@yahoogroups.com, timgerr [EMAIL PROTECTED] wrote:

 Hello all,
 I am getting this error when I add an event listener like this to a
 lable and then calling the event.target.id.  Here is the error:
 
 #1069: Property id not found on mx.core.UITextField and there is no
 default value
 
 Here is the code:
 import mx.controls.Label;
   private function WTF():void
   {
   var lbl:Label = new Label();
   lbl.text = 'Testing measdfasdfas';
   lbl.addEventListener(MouseEvent.CLICK,DOME);
   lbl.id = 'KKSKS';
   addChild(lbl);
   }
   private function DOME(evt:MouseEvent):void
   {
   trace(evt.target.id);
   }
 
 
 I get the error when the evt.target.id is called, I am not sure why
 this error is being called.  Is there another way to get the label's id?
 
 Thanks,
 timgerr





[flexcoders] Re: Getting error when trying to get id of label when adding evt listener

2008-07-23 Thread timgerr
Thanks, for the info, I never new about the currentTarget.

timgerr

--- In flexcoders@yahoogroups.com, Michael VanDaniker [EMAIL PROTECTED]
wrote:

 You want to look at the event's currentTarget instead of target.
 
 From the documentation for MouseEvent:
 
 target = The InteractiveObject instance under the pointing device. The
 target is not always the object in the display list that registered
 the event listener. Use the currentTarget property to access the
 object in the display list that is currently processing the event.
 
 --- In flexcoders@yahoogroups.com, timgerr tim.gallagher@ wrote:
 
  Hello all,
  I am getting this error when I add an event listener like this to a
  lable and then calling the event.target.id.  Here is the error:
  
  #1069: Property id not found on mx.core.UITextField and there is no
  default value
  
  Here is the code:
  import mx.controls.Label;
  private function WTF():void
  {
  var lbl:Label = new Label();
  lbl.text = 'Testing measdfasdfas';
  lbl.addEventListener(MouseEvent.CLICK,DOME);
  lbl.id = 'KKSKS';
  addChild(lbl);
  }
  private function DOME(evt:MouseEvent):void
  {
  trace(evt.target.id);
  }
  
  
  I get the error when the evt.target.id is called, I am not sure why
  this error is being called.  Is there another way to get the
label's id?
  
  Thanks,
  timgerr