PDA

View Full Version : MouseEvent.DOUBLE_CLICK issues!



absolutezero342
October 17th, 2007, 05:37 PM
Do you have to perform some kind of VooDoo magic to get MouseEvent.DOUBLE_CLICK to work? here's my code:


import flash.events.*;
box_mc.addEventListener(MouseEvent.DOUBLE_CLICK, openFolder);
function openFolder(e:MouseEvent):void {
trace("open");
}

super simple code, just have "box_mc" on the main timeline, first frame.
thx for the feedback!

senocular
October 17th, 2007, 05:43 PM
http://livedocs.adobe.com/flex/201/langref/flash/display/InteractiveObject.html#doubleClickEnabled

luxmiami
August 3rd, 2008, 09:58 PM
try this:

import flash.events.*;

box_mc.doubleClickEnabled = true;
box_mc.addEventListener(MouseEvent.DOUBLE_CLICK, openFolder);
function openFolder(e:MouseEvent):void {
trace("open");
}

gyurxi551
January 25th, 2009, 03:52 PM
Hi,
thx for the examples, but now I've another issue.
Based on your code:


import flash.events.*;

box_mc.doubleClickEnabled = true;
box_mc.addEventListener(MouseEvent.DOUBLE_CLICK, openFolder2);
function openFolder2(e:MouseEvent):void {
trace("Double open");
}


box_mc.addEventListener(MouseEvent.MOUSE_DOWN, openFolder);
function openFolder(e:MouseEvent):void {
trace("Simple open");
}

Trace code:
Simple open
Simple open
Double open
Is there any way to block Simple mousedown when DBLClick launched? I:-) I tried useCapture but nothing changed. I tried event priority as I've seen in another topic, but result's the same.

3 years ago that was my same issue in AS2. I thougt AS3 now very smart and here is MouseEvent.DOUBLE_CLICK event that can handle it. :crying:
In this moment I think it isn't much better.
Thanks
Gyurci

gyurxi551
January 25th, 2009, 04:48 PM
I wrote this workaround, rough but working:



// @code by gyurxi[at]gmail[dot]com
var clickNum:Number = 0
var littleTimer:Timer = new Timer(250,1);
littleTimer.addEventListener(TimerEvent.TIMER, doTheClick);
function doTheClick(event:TimerEvent):void{
if(clickNum == 1) {
justClickedOnce();
littleTimer.stop()
clickNum=0
}
else{
doubleClk();
littleTimer.stop()
clickNum=0
}
}


mc.addEventListener(MouseEvent.CLICK,clickFn);
function clickFn(event:MouseEvent):void{
clickNum++
littleTimer.start()

}
function justClickedOnce(){
trace("Simple Click")

}
function doubleClk(){
trace("Double Click")
}