Well, scrollbars tend to catch the mouse
events and stop them from propagating if you happen to be over them. I suppose
that could be it. Try using capture for the DragItemEvent and see if you then
see it. Firstcomp.addEventListener(…, onMouseDown, true). If you start
receiving the event then you’ll know that the newer component is getting
the event and preventing it from propagating. You can use the capture phase to
avoid that.
Matt
From:
[email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Langeberg
Sent: Wednesday, March 01, 2006
10:14 AM
To: [email protected]
Subject: [flexcoders] Flex 2:
Custom events disappearing
I've got a component with
a button (called dragBar) on it. The listener is set up as:
<firstComp>
dragBar.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
private function onMouseDown(e:MouseEvent):void
{
e.stopPropagation();
dispatchEvent(new DragItemEvent(MouseEvent.MOUSE_DOWN,
e.stageX, e.stageY));
}
</firstComp>
I'm firing a custom event, as you can see (DragItemEvent). This is caught in a
second component using this:
<secondComp>
firstComp.addEventListener(DragItemEvent.MOUSE_DOWN, onMouseDown);
private function onMouseDown (e:DragItemEvent):void {
//do stuff..
}
</secondComp>
package com.imagetrend.events
{
import flash.events.Event;
public class DragItemEvent extends Event
{
public static const MOUSE_DOWN:String =
"mouseDown";
public var stageX:Number;
public var stageY:Number;
public function
DragItemEvent(type:String, x:Number, y:Number) {
super(type, true,
true);
stageX = x;
stageY = y;
}
}
}
When I add flex buttons to the first component there's no problems.
My problem is when I add a UIcomponent such as ControlBar or anything that
scrolls, the onMouseDown() still fires in the first, but I'm no longer catching
that DragItemEvent in the second component. Any ideas why flex's components
would mess up my dispatching or listening?
--
: : ) Scott
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS