1 /** 2 * com.sekati.time.TimeOut 3 * @version 1.0.0 4 * @author jason m horwitz | sekati.com | tendercreative.com 5 * Copyright (C) 2007 jason m horwitz, Sekat LLC. All Rights Reserved. 6 * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php 7 */ 8 9 /** 10 * TimeOut 11 * {@code Usage: 12 * var t:TimeOut = new TimeOut(testFn, 500, [arg0, arg1, foo]); 13 * } 14 */ 15 class com.sekati.time.TimeOut { 16 17 private var _this:TimeOut; 18 private var _INTERVAL:Number; 19 20 /** 21 * Constructor 22 * @param f (Function) 23 * @param ms (Number) 24 * @param args (Array) 25 */ 26 public function TimeOut(f:Function, ms:Number, args:Array) { 27 _this = this; 28 var fn:Function = function():Void { 29 f.apply( null, args ); 30 _this.clear( ); 31 }; 32 _INTERVAL = setInterval( fn, ms ); 33 } 34 35 /** 36 * Clear TimeOut interval 37 * @return Void 38 */ 39 public function clear():Void { 40 clearInterval( INTERVAL ); 41 } 42 }