Skip to main content
Participating Frequently
March 16, 2011
Answered

Double Click on Graphic in Map is not Working

  • March 16, 2011
  • 1 reply
  • 1002 views

Hi,
I had created an application where the user can click on map and a marker will be created and it stores x y values and stored in database and user can also drag the marker and place it to appropriate position and after the user drag and drop the marker we have a confirm button to send the x y values to database. I need to remove that confirm button and replace that with the double click where user double clicks the marker parameters should pass.

For dragging marker i use mousedown event, but when i add doubleclick event its not working

gr.doubleClickEnabled = true;
gr.addEventListener(MouseEvent.DOUBLE_CLICK,registerComplaint);
gr.addEventListener(MouseEvent.MOUSE_DOWN,mousedownGraphic);

even when i comment the mouse down event double click on graphic marker is not working.

Help me out in this task as i need to do urgently.

Regards
Arun Mohan

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

Hi,

For  MouseEvent.MOUSE_DOWN the trace() method is working ,for DOUBLE_CLICK event there is no action.

Regards

Arun Mohan


While I can't possibly guess the cause your problem, there is an easy workaround for this.

...

// record the time for the last mouse down

private var _lastMouseDownTime:uint = new Date().time;

// how fast the second mouse down needs to be to qualify for double click
private var _doubleClickThreshold:uint = 500;

...

// traces mouse down and double click

private function mouseDown(e:MouseEvent):void {
            trace("mousedown");
            var mouseDownTime:uint = new Date().time;
            if(mouseDownTime - _lastMouseDownTime <= _doubleClickThreshold){
                trace("doubleclick");
            }
            _lastMouseDownTime = mouseDownTime;
}

1 reply

Kenneth Kawamoto
Community Expert
Community Expert
March 16, 2011

I cannot tell why it's not working for you from the info you provided, but you certainly can listen to both MouseEvent.MOUSE_DOWN and MouseEvent.DOUBLE_CLICK to get both events registered. Can you trace() on MouseEvent.DOUBLE_CLICK?

Participating Frequently
March 16, 2011

Hi,

I tried trace() on  MouseEvent.DOUBLE_CLICK even its not working,Let me know If you need furthure info about the code.

Regards

Arun Mohan

Kenneth Kawamoto
Community Expert
Community Expert
March 16, 2011

But you get trace() on MouseEvent.MOUSE_DOWN, right? Can you comment your code out so that both functions for MOUSE_DOWN and DOUBLE_CLICK have only trace() in them and test?