Delay execution of a method

Something simlar to the "delay" function in C

Page 1 of 1

1 Replies - 3387 Views - Last Post: 05 May 2009 - 08:45 PM

#1 ruslan40  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 34
  • Joined: 13-September 08

Delay execution of a method

Post icon  Posted 05 May 2009 - 01:43 PM

Is there a keyword/function I can use (in Flex/Flash AS3) to delay the execution of a method for several microseconds? Similar to the "delay" command in C. I need to do this without setting up a timer, since I need the actual execution of the method to halt where it is.
This is needed for a resource lock mechanism.

do {
	trace("LoadWeeks: Waiting for lock");
} while( lock != false);



What do I put in that loop?
Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Delay execution of a method

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1155
  • View blog
  • Posts: 7,167
  • Joined: 07-September 06

Re: Delay execution of a method

Posted 05 May 2009 - 08:45 PM

It doesn't looks like AS has a sleep, or wait function, so the closest thing you can easily do is like so:

var startTime = getTimer();
while(true){
  if(getTimer() - startTime >= sleepTime){
	break;
  }
}


where sleepTime is the time you want to wait.

HTH
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1