If you read the spec, the listeners are not assigned by phases.  There
is just capture phase, or non-capture phase.  Non-capture listeners get
all target and bubble phase events at that node in the DOM.
e.stopPropagation only prevents bubble listeners higher up in the DOM
from getting the event assuming the event is bubbling which most are
not.

 

To make sure that your listener is only responding to events in the
target phase, you test e.eventPhase

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of dsds99
Sent: Wednesday, March 12, 2008 12:53 PM
To: [email protected]
Subject: [flexcoders] Re: Debugging manual drag and drop events

 

"Nope, that's correct behavior. There is no capture phase on the target,

but then there is no bubble phase on the target either
so then it should output nothing as well...

ok i'm abit confused

i do understand that there is the capture phase, target phase, then
bubble phase

but the way it works is that you can set the addEventListener to be
set only in the bubble phase by default or capture phase.

So, to only be at the target phase, you have to use the bubble phase
and use e.stopPropagation();

So bsically the target phase is recognized as part of the bubble phase.

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Nope, that's correct behavior. There is no capture phase on the
target,
> only on its parents.
> http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-flow
<http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-flow> 
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of dsds99
> Sent: Wednesday, March 12, 2008 11:46 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Debugging manual drag and drop events
> 
> 
> 
> Ok I drag the green box onto the white one during the capture phase
> 
> bigBox.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler)
> output = "Entered bigBox"
> 
> Now if I set it to capture phase
> bigBox.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler,true)
> output = nothing
> 
> I think the output should still be "Entered bigBox"
> 
> I attached the code below
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
> layout="absolute" xmlns:local="*" creationComplete="init()">
> <mx:Script>
> <![CDATA[
> import flash.events.MouseEvent;
> import mx.core.UIComponent;
> import mx.events.DragEvent;
> import mx.managers.DragManager;
> 
> public var bigBox:UIComponent = new UIComponent();
> public var dragBox:UIComponent = new UIComponent();
> 
> public function init():void{
> bigBox.graphics.beginFill(0xffffff);
> bigBox.graphics.drawRect(0,0,100,100);
> bigBox.name = "bigBox";
> 
> dragBox.graphics.beginFill(0x234232);
> dragBox.graphics.drawRect(200,0,100,100);
> 
> dragBox.addEventListener(MouseEvent.MOUSE_DOWN,onStartDrag);
> bigBox.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler,true);
> 
> this.addChild(bigBox);
> this.addChild(dragBox);
> 
> }
> 
> 
> private function dragEnterHandler(event:DragEvent):void
> {
> trace("enter "+ event.currentTarget.name);
> // Accept the drop.
> DragManager.acceptDragDrop(event.currentTarget as
> UIComponent);
> 
> }
> private function onStartDrag(e:MouseEvent):void
> {
> DragManager.doDrag(e.currentTarget as
> UIComponent,null,e,e.currentTarget as UIComponent);
> }
> 
> ]]>
> </mx:Script>
> 
> </mx:Application>
>

 

Reply via email to