I am using as3. My sprites are not working correctly on hittestpoint in a wh开发者_JAVA技巧ile loop. I think this is because it is going too fast before it can update the display. So I would like to add a delay to the while loop. What is the easiest way to do this?
Like:
while (condition){
MAIN CODE HERE
CODE FOR DELAY OF 20ms
}
How can I do a delay in as3?
You could use a Timer instead of the loop.
or a recursive function with some delay built in: I normally use the TweenLite library for a lot of things including things like you´re trying to do..
something like that:
import com.greensock.TweenLite;
recurse();
function recurse():void{
yourCodeHere;
TweenLite.delayedCall(0.02, recurse);
}
精彩评论