Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to halt execution in ActionScript

Is there any way to halt execution in ActionScript, such as a sleep() method?

I know that there is a setTimeout() method, but setTimeout() just sets up an event for deferred execution.

like image 893
Robert Claypool Avatar asked Oct 01 '09 22:10

Robert Claypool


2 Answers

You need to think in terms of not sleeping. Actionscript is not that kind of language. Because the flash player alternates between frame renders and code execution, sleeping in the code is always a bad idea, which is why there is no method to do it.

Having said that, you could achieve this by using the blocking method ExternalInterface.call, and in Javascript executing a blocking method (like XHR request).

Absolutely idiotic though, so don't do it.

Perhaps what you need is a Timer.

like image 22
Tom Avatar answered Nov 07 '22 00:11

Tom


No. There is no sleep. Sorry.

See my answer here for options: ActionScript: pushing a closure onto the event stack?. It doesn't talk about sleeping, but I tried to provide an overview of deferred function calling.

like image 123
Glenn Avatar answered Nov 06 '22 22:11

Glenn