Created
March 5, 2009 19:14
-
-
Save func09/74498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 関数クラスのユーティリティメソッド | |
* @author Mitsuru Haga <[email protected]> | |
* @version 2009/03/02 23:10 | |
*/ | |
class com.func09.utils.FunctionUtil { | |
/** | |
* スコープ付き関数を取得する | |
* @param func | |
* @param target | |
* @return スコープを委譲したメソッドオブジェクト | |
*/ | |
public static function bind( func:Function, target:Object ):Function{ | |
return function(){ | |
func.apply( target, arguments); | |
}; | |
} | |
/** | |
* 遅延関数を取得する | |
* @param func | |
* @param duration | |
* @return 遅延実行されるメソッドオブジェクト | |
*/ | |
public static function delay( func:Function, duration:Number ):Function{ | |
return function(){ | |
var id:Number = setInterval( func, duration, arguments ); | |
var did:Number = setInterval( function(){ clearInterval(id); }, duration + 1 ); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment