Anyone knows how make a delay in flash?

I’d like to have an animated kung fu guy throwing punches…to make the punch look real…apart from using motion tween, is there a script or technique to make it look kinda like a slow motion movement with lots of delay?

help?

Do this in each frame:

start = getTimer ();
while (start+XXXX>now) {
now = getTimer ();
}

Where XXXX is the delay in milliseconds, e.g. 1000 = 1 sec.
Maybe not the most elegant solution but with this you can tweak the delay individually in each frame, I like it a lot :wink:

Achnor

Hey Achnor, what is this supposed to do ?

pom 0]

It causes a delay? Explain what you don’t understand.

Achnor

Beware though, it occupies 100% of your CPU so better not make big delays. I’ve found delays upto 0,5 seconds to work good.

Achnor

Oh, you mean you want to keep the CPU working as long as the pause lasts ?? That’s a little bit radical. You have some much more simple ways of doing that… Just putting a stop, timing and then going to the next frame. I didn’t try it, but it should be possible.
pom 0]

Do I sence I bit of sarcasm? :wink:

What I meant is that this script runs as fast as it can. It’s not bound by the framerate. If you have a slow computer, the script executes slow but the delay is the same as with a fast computer where the script executes fast.

If you know a better method (stop, timing?) please let me/us know.

Achnor

No sarcasm at all, really. Anyway, the method I was mentionning was made by Supra, so I can’t brag or anything… It’s a bit complicated to write, so if you want it, just tell me and I’ll send it to you.
pom 0]

Send it here: [email protected]

I have use for delay-scripts all the time and the more the merrier :slight_smile:

Thanks

Achnor

sent.
pom 0]

Here is the delay effect result im trying to achieve. However, im doing this by “stacking” one movie on top of the other - and adjusting its alpha levels and frame position.

www.skillfish.com/delay.swf

I’m wondering if there is a script that can be attached to a moving movie( object) that will produce similar results

thanks again

duplicateMovieClip, or you can use onion skins…i’m not sure about the onion skin one though…Pom might know…

Give me your email address, I’ll send you the fla. And yes, Jubby, I checked the profile, it says private :lol:
Mail me at [email protected] if you don’t want to write your address on the board.
pom 0]

By the way, this has absolutely nothing to do with what Achnor and I were talking about. A bon entendeur…
pom 0]

hey POM… you guys are always so helpful! I try to keep a folder with tips and stuff that I may use in the future. If it’s some cool code, could we still post it out here somewhere?

If not, I’d still love a copy of any code (as long as I know what its supposed to do) for my records.

Thanks a million!

[email protected]

thanks for the code.

its very similar to the delay im talking about.- except that it moves with the mouse. Can i extract it and apply it to a movie?

Just found this code-snippet. It behaves the same way as the other A/C I posted but without hogging the CPU:

onClipEvent (enterFrame) {
if (_root.delay) {
if (_root.waitHowLong<=(getTimer()/1000)-_root.startTime) {
// Time is up!
_root.delay = false;
} else {
// Keep waiting…
}
}
}

Source:
www.actionscript.org/tuto…ndex.shtml