forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwait.as
More file actions
28 lines (27 loc) · 664 Bytes
/
wait.as
File metadata and controls
28 lines (27 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package utils.display
{
import flash.display.Shape;
import flash.events.Event;
/**
* Wait a given number of frames then call a callback
* @param numFrames Number of frames to wait before calling the callback
* @param callback Function to call once the given number of frames have passed
* @author Jackson Dunstan
*/
public function wait(numFrames:uint, callback:Function):void
{
var obj:Shape = new Shape();
obj.addEventListener(
Event.ENTER_FRAME,
function(ev:Event):void
{
numFrames--;
if (numFrames == 0)
{
obj.removeEventListener(Event.ENTER_FRAME, arguments.callee);
callback();
}
}
);
}
}