Hi,

yeah he timer class does it but;

function example {
trace("before");
sleep(2000);
trace("after 2 seconds");
}

Will not work. The Flash player exectues in order of the stack. So, you
can't have a sleep method inside a method block and halt the method block.

Although something like this might be what you looking for.

function example {
trace("before");
sleep(2000, exectueAfter, "something", 1);
}

function sleep(milli:Number, func:Function, ...rest):void
{
callMethod = func
callArgs = rest
... set up timer and handlers, run timer
}

function timer_timerEndHandler(event:TimerEvent):void
{
  callMethod(callArgs)
}

function exectueAfter(arg1, arg2)
{
trace("after 2 seconds");
}

This is about as close as you will get to a 'sleep' method.

Peace, Mike

On 2/14/07, Igor Costa <[EMAIL PROTECTED]> wrote:

  Conley

You could check out the Timer Class that can do this for you exactly in
the way you need it.


On 2/14/07, j.conley < [EMAIL PROTECTED]> wrote:
>
>
> I was wondering if there are any plans to consider continuation
> support in flash/flex? ...predominantly to support the concept of a
> smarter "Thread.sleep(n)" without blocking or disrupting the
> single-threaded execution model.
>
> for context, here is a "sleep" pseudo-example using the continuations
> concept:
>
> function example {
> trace("before");
> sleep(2000);
> trace("after 2 seconds");
> }
>
> function sleep(sleep_millis:int) {
> var savepoint:Continuation = Continuations.new(); // creates a
> holder that will capture the execution stack state at the next suspend()
> setTimeout(function(event:Event):void {
> Continuations.resume(savepoint); // resumes the
> saved execution stack
> },sleep_millis);
> Continuations.suspend(savepoint);
> }
>
> For my purposes, I am writing a general-purpose tool for developers
> that would locate one or more components in the UI hierarchy (by some
> criteria), then return those components so they could interact with
> them.
> In searching for said components, I have come across embedded
> SWFLoaders which are not yet finished loading/reloading, and sleep()
> (via continuations) would allow checking it's state periodically and
> not disrupt the execution stack, callers code or block the overall
> application.
>
> There are several other cases where this would be useful, but I just
> wanted to start a dialog on it.
>
>


--
----------------------------
Igor Costa
www.igorcosta.org
www.igorcosta.com
skype: igorpcosta




--
Teoti Graphix
http://www.teotigraphix.com

Blog - Flex2Components
http://www.flex2components.com

You can find more by solving the problem then by 'asking the question'.

Reply via email to