AS3 Delay Timer Execute and Start Timer

Hello I have a ActionScript 3.0 project and I have a timer that is running on 1000 millisecond intervals. I would like to delay this timer for 1500 milliseconds perform an action and start the timer again after the delay. I thought I could do this easily, but I'm having trouble, would it be better to stop the timer and perform the action and then listen for the action to be completed to start the timer again? If you have time, I would appreciate the help. Thank you, Scientific

Answers


Assuming I understood your question, why not something like this? (UNTESTED CODE)

yourTimer.addEventListener(TimerEvent.TIMER, itIsTime);

function itIsTime(evt:TimerEvent):void {
  yourTimer.stop();
  yourTimer.reset();
  if(yourTimer.delay == 1500){
    //Do your stuff
    ...
    yourTimer.delay = 1000;
    yourTimer.start();
  } else {
    //Do your stuff
    ...
    yourTimer.delay = 1500;
    yourTimer.start();
  }
}

Alternatively you could use 2 timers, but the idea is the same, after 1000 do one thing, after 1500 do something different, controlling when each timer goes off with the other timer's listener function.


Need Your Help

Drag and drop files to be uploaded when the form is submitted

php jquery html upload drag-and-drop

I'm trying to implement drag-and-drop file selection for uploading files synchronously once the form is submitted. I know how regular file uploading works with HTML and PHP. And I want to be able to

How do I get the compact form of pretty-printed JSON code?

java json jackson pretty-print

How do I make Jackson pretty-print the JSON content it generates? Here is an example that pretty-prints the ugly form of JSON code. I need to take the nice version of JSON code then convet it to ugly

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.