Given the following:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="creationCompleteHandler()">
<mx:Script>
<![CDATA[
private function creationCompleteHandler():void
{
but.doubleClickEnabled = true;
but.addEventListener(MouseEvent.CLICK, onMouseClick);
but.addEventListener(MouseEvent.DOUBLE_CLICK,
onMouseDblClick);
cvs.addEventListener(MouseEvent.MOUSE_DOWN,
onMouseDown);
}
private function onMouseClick(event:MouseEvent):void
{
trace("onMouseClick");
}
private function onMouseDown(event:MouseEvent):void
{
trace("onMouseDown");
}
private function onMouseDblClick(event:MouseEvent):void
{
trace("onMouseDblClick");
}
]]>
</mx:Script>
<mx:Canvas id="cvs" width="300" height="200">
<mx:Button id="but" width="100" height="75" label="Hello"/>
</mx:Canvas>
</mx:Application>
I get the following output if I double click the button:
onMouseDown
onMouseClick
onMouseDown
onMouseDblClick
--- In [email protected], "Vijay Ganesan" <[EMAIL PROTECTED]>
wrote:
>
>
> I need to handle MOUSE_DOWN because I'm enabling drag and drop.
> Again the weird thing is that the AIR version works fine.
>
> --- In [email protected], "valdhor" stevedepp@ wrote:
> >
> > Don't quote me on this but it is probably because the
> > MouseEvent.MOUSE_DOWN event is captured before a double click. If
you
> > change the event listener from MouseEvent.MOUSE_DOWN to
> > MouseEvent.CLICK then it works as expected.
> >
> >
> > --- In [email protected], "Vijay Ganesan"
> > <vijay.k.ganesan@> wrote:
> > >
> > > I have the same code running in an AIR app and in a browser app -
the
> > > only difference being the containing mx:WindowedApplication versus
> > > mx:Application. See code below for both. Double clicking on the
button
> > > in the AIR app works fine (MouseEvent.DOUBLE_CLICK gets fired) but
the
> > > same does not fire in the browser version. Can someone tell me
what is
> > > going on here?
> > >
> > > Thanks
> > > Vijay
> > >
> > > AIR version:
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
> > > layout="absolute" creationComplete="creationCompleteHandler()">
> > > <mx:Script>
> > > <![CDATA[
> > > import mx.managers.DragManager;
> > > import mx.core.DragSource;
> > >
> > > private function creationCompleteHandler():void
> > > {
> > > cvs.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
> > > but.doubleClickEnabled = true;
> > > but.addEventListener(MouseEvent.DOUBLE_CLICK, onMouseDblClick);
> > > }
> > >
> > > private function onMouseDown(event:MouseEvent):void
> > > {
> > > trace("onMouseDown");
> > > var ds:DragSource = new DragSource();
> > > DragManager.doDrag(this, ds, event);
> > > }
> > >
> > > private function onMouseDblClick(event:MouseEvent):void
> > > {
> > > trace("onMouseDblClick"); // gets called as expected
> > > }
> > > ]]>
> > > </mx:Script>
> > >
> > > <mx:Canvas id="cvs" width="300" height="200">
> > > <mx:Button id="but" width="100" height="75" label="Hello"/>
> > > </mx:Canvas>
> > >
> > > </mx:WindowedApplication>
> > >
> > > Browser version:
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> > > layout="absolute" creationComplete="creationCompleteHandler()">
> > > <mx:Script>
> > > <![CDATA[
> > > import mx.managers.DragManager;
> > > import mx.core.DragSource;
> > >
> > > private function creationCompleteHandler():void
> > > {
> > > cvs.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
> > > but.doubleClickEnabled = true;
> > > but.addEventListener(MouseEvent.DOUBLE_CLICK, onMouseDblClick);
> > > }
> > >
> > > private function onMouseDown(event:MouseEvent):void
> > > {
> > > trace("onMouseDown");
> > > var ds:DragSource = new DragSource();
> > > DragManager.doDrag(this, ds, event);
> > > }
> > >
> > > private function onMouseDblClick(event:MouseEvent):void
> > > {
> > > trace("onMouseDblClick"); // does not get called!!!
> > > }
> > > ]]>
> > > </mx:Script>
> > >
> > > <mx:Canvas id="cvs" width="300" height="200">
> > > <mx:Button id="but" width="100" height="75" label="Hello"/>
> > > </mx:Canvas>
> > >
> > > </mx:Application>
> > >
> >
>