Purpose of CurrentTarget and Target

3 views
Skip to first unread message

Noorul

unread,
Feb 6, 2012, 4:48:26 AM2/6/12
to Flex India Community
I was asked the following questions in interview

What is the currentTarget,Target in Flex

plz advice.

Akki

unread,
Feb 7, 2012, 10:05:19 PM2/7/12
to Flex India Community
Hi Noorul,

They are two different properties associated with an event. Consider
the following scenario:

<s:Application>
<s:Panel>
<s:Button/>
</s:Panel>
</s:Application>

If an event is dispatched by the button it will go thru capture,
target and bubble phase and traverse as shown:

Capture Phase Target Bubble
Application -> Panel -> Button -> Panel->Application

The currentTarget will always refer to the component where event is
currently located while going thu this cycle. For example the
currentTarget(ct) and target(t)
will change as:
Capture Phase Target
Bubble
Application -> Panel -> Button -> Panel-
>Application
ct:Application Panel Button
Panel Application
t:Button Button Button
Button Button

So at target phase they will both be same.

Thanks,
Akhil Mittal

bala subramanyam

unread,
Feb 7, 2012, 10:25:14 PM2/7/12
to flex_...@googlegroups.com
Hi Noorul,

display object which dispatches the event is event.target
display object which listens to the event is event.currentTarget

Regards
Balu


--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.




--
Baluvasireddy

Priti Gupta

unread,
Feb 7, 2012, 9:54:51 AM2/7/12
to flex_...@googlegroups.com
current target and target-----

current target is that where you registered your listener and target is that where you dispatches your event.

Janibasha Mca

unread,
Feb 8, 2012, 12:27:50 AM2/8/12
to flex_...@googlegroups.com
let us take you have a button in the panel .
the target is button that can not be change.
if you click on the panel then the current current target is panel.
the current target can change but target remains same.

--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.




--
Thanks & Regards,
JaniBasha.sk
09962030340
Email:janiba...@gmail.com

Nitin Gopi

unread,
Feb 7, 2012, 8:45:39 AM2/7/12
to flex_...@googlegroups.com
Hi Noorul,
The current target always specifies to the object with which the eventlistener is attached.
The target is the object with dispatches the event.
For example
Suppose you have a button inside a panel. You add event listener to the panel. Then you click on the button.During event propagation the event will be listened which is associated with the panel. But since it was the button which dispatched the event, it is the target.
Whereas if you had clicked on the panel, then in this case the current target and target both are the same , the panel.
I hope that it proved useful to you. You can ask again if you want more clarification.

With Regards,
Nitin

On Mon, Feb 6, 2012 at 3:18 PM, Noorul <nooru...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.




--
You can only depend on yourself. The cavalry ain't coming.

Akki

unread,
Feb 10, 2012, 1:16:32 AM2/10/12
to Flex India Community
Hi,

I have recently posted about events at the following URL:

http://flex4java.blogspot.com/
that will help you in clarifying most of the doubts. If you have any
suggestion/comments please share :)

Thanks,
Akhil

On Feb 7, 9:05 pm, Akki <contacttoak...@gmail.com> wrote:
> Hi Noorul,
>
> They are two different properties associated with an event. Consider
> the following scenario:
>
> <s:Application>
>    <s:Panel>
>       <s:Button/>
>    </s:Panel>
> </s:Application>
>
> If an event is dispatched by the button it will go thru capture,targetand bubble phase and traverse as shown:
>
> Capture Phase              Target          Bubble
> Application -> Panel ->   Button  ->     Panel->Application
>
> ThecurrentTargetwill always refer to the component where event is
> currently located while going thu this cycle. For example thecurrentTarget(ct) andtarget(t)
>  will change as:
> Capture Phase                                      Target
> Bubble
> Application                         -> Panel ->   Button  ->     Panel->Application
>
> ct:Application                          Panel       Button
> Panel   Application
> t:Button                                 Button       Button
> Button    Button
>
> So attargetphase they will both be same.
Reply all
Reply to author
Forward
0 new messages