Hok's Macromedia Flash Blog

macromedia flash actionscript scripting, php, remoting, webservices, c#, javascript

Ads

Search

MovieClip-Extension: onDoubleClick

I think that is an old-one, but maybe there is
someone who need it.
It is an onDoubleClick-Handler for MovieClips.
The code is little spaghetti-like...;-) But for this
job it is OK.
I had some problems with side-effekts because
i wanted to use: onPress as helper for the new
event. The concrete Problem is that we can't
define the onPress-Handler after the onDoubleClick-
Handler.
What do you think, is there an way to get arround
this Problem?
view(code);
get(code);

Posted by hOk at May 26, 2003 01:43 PM

Comments (10)

Hi!
I don't understand, do you have a problem with the doubleclick?
Your solution seems very nice,

I post another version that I'm using now. And seems to look as yours.
Here it is:


// MovieClip.onDoubleClick Event v1.0
// by Jonas Galvez (jonas@onrelease.org)

MovieClip.prototype.addProperty(
"onDoubleClick",
function()
{
return this.$onDoubleClick
},
function(f)
{
this.$onDoubleClick = f;
Mouse.addListener(this);
}
);

Mouse.onMouseDown = function()
{
if(this.last_click == undefined)
this.last_click = 300;
if(getTimer() - this.last_click

Posted by Carlos at May 26, 2003 02:54 PM

I always include the following code in my projects:

Mouse.doubleClick = function(clickSpeed) {
if (!clickSpeed) {
clickSpeed = 500;
}
if (Mouse.lastclick - (Mouse.lastclick = getTimer()) + clickSpeed > 0) {
return true;
}
}

// usage example
myButton.onRelease = function (){
if (Mouse.doubleClick()){
//no exec, mouse double clicked
} else {
// put your code here to be executed only once (single)
}

Posted by cedric at May 26, 2003 05:47 PM

Hey... Nice code! I too had that onPress problem so I decided to attach the necessary code to the Mouse object. Dunno if it's the best approach, but it is working fine... =)

http://www.onrelease.org/jonas/scripts/movieclip_ondoubleclick.html
(the URL of the code Carlos posted =)

Posted by Jonas Galvez at May 26, 2003 06:57 PM

Yeah, thanks for that, looks also good,
maybe i will switch to it.
regards, Holger

Posted by hOk at May 27, 2003 05:02 PM

Hi! I notice that if you have code in the onPress or onRelease function that code will execute...
If that code is CPU intensive...there's a problem to use the onDoubleClick...

should be a way to deactivate onPress and onRelease events when trigger a onDoubleClick event.

C.

Posted by Carlos at June 13, 2003 09:38 AM

I tried to use your code for some sort of a switching behaviour and I noticed that if I click three times for 500ms the doubleClick code executes twice. I made this little fix that solves my problem:


if (this.__lastClick__ + 500 > getTimer()) {
this.__onDoubleClick__();
this.__lastClick__ = this.__lastClick__ - 500;
} else {
this.__onPress__();
this.__lastClick__ = getTimer();
}


It seems that this issue also appears with the Mouse related extension. Yours works better for me, because it utilizes the button behaviour of the MovieClip and does not bubbles in cases with overlaped clips.

Posted by Rostislav at June 25, 2003 03:02 PM

Thank you,
i have integrated that fix.
regards, Holger

Posted by hOk at June 26, 2003 07:20 PM

LOL. I've been having onPress problems for a long time too.

Posted by Online Coupons at November 1, 2003 10:27 PM

Cedric! Thanks a million for your anti-doubleclick script. It works excellent! You really saved me with it.

Keep up the good work.

Sabine (a starting flash developer)

Posted by Sabine at November 19, 2003 12:35 PM

Hey hOk!

This is cool stuff! I'm fairly experienced in Flash, but embedding in Win32 apps is new to me.

Do you have any experience with embedding Flash in Delphi? I'm getting everything to work, except the flash window won't resize even though i resize the component. Do you have a tip?

Ok, thanks for your time, and thanks for valuable info on this page!

Best regards,


Johan Telstad, Norway

Posted by Johan Telstad at December 12, 2003 12:04 AM


Name:


Email Address:


URL:


Comments:



You can use <code>code that should be highlightned</code> to highlight code!
Optionally you can use the attribut language="php|perl|java" within the code tag, otherwise
actionscript-highlightning will be used.

New Place