Skip to main content
Inspiring
November 25, 2011
Question

How to perform "double click" event in ActionScript 2.0

  • November 25, 2011
  • 2 replies
  • 4057 views

Hi,

i have a movieClip on which i have to perform a "double click" event so is there any Event or procedure to perform this event like we have "MouseEvent.DOUBLE_CLICK" in AS3.

i have used the code

dbc.onRelease = dbClick;

function dbClick(){

    if(lastclick - (lastclick=getTimer()) + 500 > 0){

           dbC.text = "double click"

    } else {

                       return;

    }

}

its working when i used this code on frame but this code is not working on external AS file. the error related to lastclick.

is there any code like..  "instanceName.addEventListener('DoubleClick', functionName);" in AS2

Looking for your help ..

Thanks in advance

This topic has been closed for replies.

2 replies

Inspiring
December 4, 2011

is lastclick defined in the external as file? is it being set to the correct value for getTimer()?

iawaraAuthor
Inspiring
December 8, 2011

Thanks for your reply.

i am using this code

AS2:

dbc.onRelease = dbClick;

var lastclick:Number;

function dbClick(){

    if(lastclick - (lastclick=getTimer()) + 500 > 0){

          trace("doubleclick");

    } else {

                      trace("single click");

    }

}

when i clicked on dbc button two times(double click) first it trace "single click" then "double click" and here i want only "double click"

Please reply.

kglad
Community Expert
Community Expert
December 8, 2011

use:

dbc.onRelease = dbClick;

var lastclick:Number;

function dbClick(){

    if(lastclick - (lastclick=getTimer()) + 500 > 0){

          trace("doubleclick");

    }

}

p.s.  please mark helpful/correct responses.

Ned Murphy
Legend
November 25, 2011

See if the following is useful for you...

http://greenethumb.com/article/24/double-click-event-in-as2/

iawaraAuthor
Inspiring
November 25, 2011

Thanks for your reply but i have already check this link before and source is not available there and they have used com classes so not useful for me..please post if you have some other solutions.

Thanks.

kglad
Community Expert
Community Expert
November 25, 2011

there's no as2 double click event like as3.  you have to code it yourself, just like you've done.

if you're code is not working, it's because you have some error that's not apparent from the code you posted.  use the trace() function to debug.