Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to wait for 3 seconds in ActionScript 2 or 3?
- public function foo(param1, param2, param3) {
- //do something here
- //wait for 3 seconds
- //3 seconds have passed, now do something more
- }
- var timer:Timer = new Timer(3000);
- timer.addEventListener(TimerEvent.TIMER, callback); // will call callback()
- timer.start();
- class Test {
- private var timer:Timer = new Timer(3000);
- public function foo(param1:int, param2:int, param3:int):void {
- // do something here
- timer.addEventListener(TimerEvent.TIMER, fooPartTwo);
- timer.start();
- }
- private function fooPartTwo(event:TimerEvent):void {
- timer.removeEventListener(TimerEvent.TIMER, fooPartTwo);
- timer = null;
- // 3 seconds have passed, now do something more
- }
- }
- function foo(param1:int, param2:int, param3:int):void {
- var x:int = 2; // you can use variables as you would normally
- // do something here
- var timer:Timer = new Timer(3000);
- var afterWaiting:Function = function(event:TimerEvent):void {
- timer.removeEventListener(TimerEvent.TIMER, afterWaiting);
- timer = null;
- // 3 seconds have passed, now do something more
- // the scope is retained and you can still refer to the variables you
- // used earlier
- x += 2;
- }
- timer.addEventListener(TimerEvent.TIMER, afterWaiting);
- timer.start();
- }
- var timer = setInterval(function, 3000, param1, param2);
- function (param1, param2) {
- // your function here
- clearInterval(timer);
- }
- TweenMax.delayedCall(1, myFunction, ["param1", 2]);
- function myFunction(param1:String, param2:Number):void
- {
- trace("called myFunction and passed params: " + param1 + ", " + param2);
- }
- public function foo(param1, param2, param3) {
- //do something here
- trace("I gonna wait 3 seconds");
- TweenMax.delayedCall(3, function()
- {
- trace("3 seconds have passed");
- });
- }
Add Comment
Please, Sign In to add comment