hey!
id like help with creating a button with the following functionality…
if u click it, it acts like normal… and runs some script or sets a value or whatever… but how do i do it so that if the mouse button is held down while on the button it would after 2 seconds keep runing whatever its told to do untill mouse button is released…
im making a volume controll button, and want it to by 1 click jump up 1 % in volume, but as this gets tedious to press , i want it to go up by 1 really fast if its held down … thanks =)
You have to create a timer in the button that starts as you press the button, and ends when release, releaseOutdide. Then you have to program the button so that when it is pressed it starts by increasing or decreasing 1%, then if the timer counts 2 seconds or whatever, it will stop the current action, and executes the other action with rapid increase/decrease ammount.
Not a really smart example… but… take a look
First you need a function
function doifhold () {
if (timepressed + 1500 < getTimer()){ // where 1500 is the time in milliseconds you want to pass before it do the actions inside.
trace("and holded - Function executed "+i++ +" times.");
}
}
And a simple button will do for the next script
on (press) {
trace ("pressed simple");
timepressed = getTimer();
holdverify = setInterval(doifhold,10);
}
on (release,releaseOutside) {
clearInterval(holdverify);
}