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