Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-26-2009, 04:59 PM   PM User | #1
pspsully
New Coder

 
Join Date: Feb 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
pspsully is an unknown quantity at this point
Make a button do something after a a certain time

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 is offline   Reply With Quote
Old 03-26-2009, 05:36 PM   PM User | #2
pspsully
New Coder

 
Join Date: Feb 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
pspsully is an unknown quantity at this point
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
pspsully is offline   Reply With Quote
Old 03-27-2009, 09:24 AM   PM User | #3
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Please put code between [ CODE ] brackets.

Code:
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...
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:38 AM.


Advertisement
Log in to turn off these ads.