PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/sh/saqoo/util/FrameDelay.as

http://github.com/Saqoosha/SAQAS3
ActionScript | 26 lines | 20 code | 6 blank | 0 comment | 4 complexity | d394285f8e9f0f503bc84d43f34a0eb0 MD5 | raw file
 1package sh.saqoo.util {
 2
 3	import flash.events.Event;
 4
 5	public class FrameDelay {
 6
 7
 8		public function FrameDelay() {
 9			throw new Error('Cannot create FrameDelay instance.');
10		}
11
12
13		public static function set(numFrames:uint, callback:Function):void {
14			if (numFrames == 0) {
15				callback();
16			} else {
17				EnterFrameBeacon.add(function(event:Event):void {
18					if (--numFrames <= 0) {
19						EnterFrameBeacon.remove(arguments.callee);
20						callback();
21					}
22				});
23			}
24		}
25	}
26}