Beau, Thanks for this code... I've got another question though, I'll post it as another thread...
Cheers, Nick 2009/9/1 Beau Scott <beau.sc...@gmail.com> > > > The only way I've been able to accomplish this is to use a timer to filter > out a double click, and then ferry the original click event to an eventual > click handler. The downside to this is the hardcoded timer delay doesn't > reflect the user's system's double-click delay, and I'm not sure how to read > that in (I'm not even sure that Flex uses this anyway). > > Example: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="horizontal" xmlns:local="*"> > <mx:Script> > <![CDATA[ > > private var doubleClickFilterTimer:Timer; > private var pendingMouseEvent:MouseEvent; > > private function button_doubClickHandler(event:MouseEvent):void > { > if(doubleClickFilterTimer) > doubleClickFilterTimer.stop(); > trace('double clicked'); > } > > private function button_clickHandler(event:MouseEvent):void > { > if(!doubleClickFilterTimer) > { > doubleClickFilterTimer = new Timer(200, 1); > > doubleClickFilterTimer.addEventListener(TimerEvent.TIMER_COMPLETE, > doubleClickFilterTimer_timerCompleteHandler); > } > else > { > doubleClickFilterTimer.reset(); > } > pendingMouseEvent = event; > doubleClickFilterTimer.start(); > } > > private function > doubleClickFilterTimer_timerCompleteHandler(event:TimerEvent):void > { > finishClickHandler(pendingMouseEvent); > pendingMouseEvent = null; > } > > private function finishClickHandler(event:MouseEvent):void > { > trace('clicked'); > } > ]]> > </mx:Script> > > <mx:Button label="Click or Double-Click Me" > click="button_clickHandler(event)" > doubleClickEnabled="true" > doubleClick="button_doubClickHandler(event)" /> > > </mx:Application> > > > > Hope that helps, > > Beau > > > On Tue, Sep 1, 2009 at 9:27 AM, Nick Middleweek <n...@middleweek.co.uk>wrote: > >> >> >> Hello, >> >> I'm having difficulty setting both a click and a doubleClick event on the >> same button. Is it possible? >> >> >> Thanks, >> Nick >> >> > > > -- > Beau D. Scott > Software Engineer > >