Link to home
Create AccountLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

add pause

for (var i:int = 0; i < img.length; i++) {
				img[i].x=img[i].x-10;
				if (img[i].x < -300) {
					img[i].x=img[i].x+900;
				}
			}

Open in new window


I want to add a 3 sec time delay when the if statement is true.
This moves an image and when the if statement is true then pause for 3 sec.

What is the best way to do this?
Avatar of jambraun
jambraun
Flag of United States of America image

I can' take credit for coming up witht he solution but I'll take credit for answering ;)  It's been years since I attempted Action Scripting.  See the link below for the full thread.

http://www.flash8forums.com/viewtopic.php?f=17&t=31

Here's the code snippet I located that may do what you want:

stop();
var nDelayID:Number = setInterval(this, "pause", 4000);
// where 4000 is 4000 milliseconds
function pause():Void {
clearInterval(nDelayID);
play();
// or nextFrame();
}
Avatar of jagguy

ASKER

no this doesnt work.

I need tomeasure time when 2-3 sec has elapsed , set a flag etc.
I think you're on track with your 'for' loop.  I wish someone else would jump in...it really has been years since I've attempted this.

You're trying to have the image move while paused?  Is the move instantaneous or does it increment over a time frame?
ASKER CERTIFIED SOLUTION
Avatar of jagguy
jagguy
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of jagguy

ASKER

i solved it