Re: [Flashcoders] AS3 - A simple questions
This sentiment is not uncommon but I still disagree. There are many instances when I want to know which element is dispatching the event. As stated, using currentTarget exclusively means you can only get a reference from the instance to which the listener is attached. Doing this all the time practically negates event cascading. I think they both have their purposes and should be used accordingly. On 6/5/08 8:17 AM, "EECOLOR" wrote: > The cases where you would use > event.target are so rare that I would urge everyone to allways use > event.currentTarget. Rich http://www.LearningActionScript3.com ___ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AS3 - A simple questions
I use event.target in the current application I'm developing.
It's nice in MouseEvents for determing what is currently under the mouse
and not what dispatches the event.
On Thu, 05 Jun 2008 14:17:43 +0200, EECOLOR <[EMAIL PROTECTED]> wrote:
I would recommend using event.currentTarget instead of event.target at
all
times.
the event.currentTarget property contains a reference to the instance at
which you registered the event listener. event.target refers to the class
that dispatches the event.
In this case there is no difference between .target and .currentTarget,
but
in future cases you might encounter problems. The cases where you would
use
event.target are so rare that I would urge everyone to allways use
event.currentTarget.
Greetz Erik
On 6/3/08, Rich Shupe <[EMAIL PROTECTED]> wrote:
for (var i:int = 0; i < 3; i++) {
var txtFld:TextField = new TextField();
txtFld.name = "TextField" + i;
txtFld.border = true;
txtFld.x = i*120;
addChild(txtFld);
txtFld.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
}
function onClick(evt:Event):void {
trace("Hi I'm", evt.target.name);
}
Rich
http://www.LearningActionScript3.com
___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AS3 - A simple questions
I would recommend using event.currentTarget instead of event.target at all
times.
the event.currentTarget property contains a reference to the instance at
which you registered the event listener. event.target refers to the class
that dispatches the event.
In this case there is no difference between .target and .currentTarget, but
in future cases you might encounter problems. The cases where you would use
event.target are so rare that I would urge everyone to allways use
event.currentTarget.
Greetz Erik
On 6/3/08, Rich Shupe <[EMAIL PROTECTED]> wrote:
>
> for (var i:int = 0; i < 3; i++) {
> var txtFld:TextField = new TextField();
> txtFld.name = "TextField" + i;
> txtFld.border = true;
> txtFld.x = i*120;
> addChild(txtFld);
> txtFld.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
> }
>
> function onClick(evt:Event):void {
> trace("Hi I'm", evt.target.name);
> }
>
>
>
> Rich
> http://www.LearningActionScript3.com
>
>
>
> ___
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AS3 - A simple questions
for (var i:int = 0; i < 3; i++) {
var txtFld:TextField = new TextField();
txtFld.name = "TextField" + i;
txtFld.border = true;
txtFld.x = i*120;
addChild(txtFld);
txtFld.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
}
function onClick(evt:Event):void {
trace("Hi I'm", evt.target.name);
}
Rich
http://www.LearningActionScript3.com
___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

