# Double Clicking button to perform action?

**URL:** https://forum.kirupa.com/t/double-clicking-button-to-perform-action/5405
**Category:** flash
**Created:** [September 10, 2002, 11:13am UTC](https://forum.kirupa.com/t/double-clicking-button-to-perform-action/5405 "2002-09-10T11:13:49Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![byis](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@byis](https://forum.kirupa.com/u/byis)
#### Post date: [September 10, 2002, 11:13am UTC](https://forum.kirupa.com/t/double-clicking-button-to-perform-action/5405/1 "2002-09-10T11:13:49Z")

</div>

I would like to have a button that on press will be able to drag and on release will stop drag. I have this done. What im trying to figure out is how to make the same button load a movie clip if you double click it.

Thanks for the help!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 10, 2002, 1:18pm UTC](https://forum.kirupa.com/t/double-clicking-button-to-perform-action/5405/2 "2002-09-10T13:18:23Z")

</div>

Here’s the code for double click that is on [Actionscripts.org](http://www.actionscript.org/actionscripts_library/main/search.cgi?query=double+click&submit=SEARCH) , I think it has exactly what your looking for.

/\*  
Inspired by Emax - Extended by Madokan  
\*/  
movieclip.prototype.doubleClick = function(speed) {  
if ( getTimer()-oldTime \<= speed ) return(true);  
oldTime=getTimer();  
clickcount=0;  
}

movieclip.prototype.tast = function () {  
if(getTimer()-timestamp\>=250 && clickcount==1){  
trace(“singleclick”);  
ausgabe = “Singleclick”;  
clickcount=0;  
}  
}

setInterval(tast, 10);

Button.prototype.onPress = function() {  
if(doubleClick(250)) {  
trace(“Doppelklick”);  
ausgabe = “Doppelklick”;   
};  
clickcount++;  
timestamp=getTimer();  
}

hope that helps,  
-Dave

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 10, 2002, 6:16pm UTC](https://forum.kirupa.com/t/double-clicking-button-to-perform-action/5405/3 "2002-09-10T18:16:49Z")

</div>

Thanks for the reply. I’ll see if I can get it working. By the way great site! NIce to hear from someone in tejas - I live in Denton…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 10, 2002, 6:31pm UTC](https://forum.kirupa.com/t/double-clicking-button-to-perform-action/5405/4 "2002-09-10T18:31:31Z")

</div>

Ok, im a bit confused on what I need to do with the AS. Should the AS listed above attached to my button or just in the layer?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 10, 2002, 7:23pm UTC](https://forum.kirupa.com/t/double-clicking-button-to-perform-action/5405/5 "2002-09-10T19:23:42Z")

</div>

I attached a simple .fla to this post. Hopefully this will help you out. I also translated some of the German in there (even though there wasn’t much) to english so you can hopefully better understand what each thing does.
