Avoid manic button press
I had to create a function where by I could avoid the button being pressed to quickly as some clicks where not being registered.
Some people will click a button as quickly as they can to see if they can break it lol.
-
var reEnable:Number;
-
button_mc.onPress = function() {
-
trace("the button was pressed");
-
disableButton(this);
-
};
-
function disableButton(b:MovieClip):Void {
-
b.enabled = false;
-
clearInterval(reEnable);
-
reEnable = setInterval(this, "reEnableButton", 1000, b);
-
}
-
function reEnableButton(b:MovieClip):Void {
-
b.enabled = true;
-
clearInterval(reEnable);
-
}
Tags: button, disable, flash, setInterval