...

View Full Version : Make a button do something after a a certain time



pspsully
03-26-2009, 05:59 PM
Hi Guys,

I have a button in Flash, i am still using Flash 8 and ActionScript 2 as thats what im used to :)

When i click the button, i want it to go and and play a different Frame so i have:


on (press){
gotoAndPlay(2);
}


But i want it to gotoAndPlay frame 2 only after 3 seconds of clicking the button.

Ideally, i would like that when the button is clicked, it will gotoAndPlay frame 2, but if you click the button and hold it for 3 seconds, it will gotoAndPlay frame 3.

Is it even possible to do that?

pspsully
03-26-2009, 06:36 PM
Ok, i made some progress, i came up with this:


on (press) {
// get start time
mousedown = getTimer();
}

on (release) {
// set time to hold down
timer = 3000;
// get finish time
mouseup = getTimer();
// calculate how long the button was pressed
difference = mouseup - mousedown;

if (difference >= timer) {
gotoAndPlay(2);
} else {
gotoAndPlay(3);
}

}


However, the problem i have now is that the button has to be released. I want to go to frame 2 while the button is still being pressed, not aftre it is released?

i have played with putting the executable code in the on (press) function but then i cannot play frame 3 when the button is released.

Any Ideas would be greatly appreciated :)

gnomeontherun
03-27-2009, 10:24 AM
Please put code between [ CODE ] brackets.


on (press) {
// get start time
mousedown = getTimer();
gotoAndStop(2);
}

on (release) {
// set time to hold down
timer = 3000;
// get finish time
mouseup = getTimer();
// calculate how long the button was pressed
difference = mouseup - mousedown;

if (difference >= timer) {
gotoAndPlay(3);
}

}

Can't say I really understand why or what you are doing here...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum