|
|
|
||||
|
||||
|
||||
A quick one this: someone asked a question at Flashkit about how to simulate a 'double click' button, a facility not provided even in Flash5. After several functional but not very clever attempts, I came up with a very simple piece of code that seems to work just fine. You'll find the demo file here.
I'm not going to go through the code line by line -- take a look at the .fla file and it's all there, with plenty of comments. Briefly, in the Button Movie's object actions is an OnClipEvent action that sets a variable called clicked to 0, when the movie first appears. The rest of the code is in the button itself, which is inside the Button Movie clip.
It works roughly like this:
- When you first click the button, it checks the time (in milliseconds) and stores it in a variable called start, and also sets the variable clicked to 1 -- indicating that the button has been clicked once and is waiting to be clicked again.
- Now that clicked is set to 1, when the button is clicked again it checks the time (with the variable stop) and if more than 300 millisconds has passed (stop - start), it simply resets the start time and goes back to waiting.
- However if less than 300 milliseconds has passed, it executes the double click actions -- in this case swapping the frame of the On - off text movie -- and sets clicked to 0, so that the button is ready for another double click event.
If you want the double click period to be longer (so you don't have to click as fast) then change the value 300 to something higher.
Please move along, there's nothing more to see here.
Good luck!
All files and text copyright ©Stickman 1998 - 2003. For copyright and terms of use information, please read this page.