Created
September 17, 2010 20:01
-
-
Save rafaelrinaldi/584840 to your computer and use it in GitHub Desktop.
Useful method to fire a function without be careful about null pointer exception.
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
package rinaldi.util | |
{ | |
/** | |
* | |
* Useful method to fire a function without be careful about null pointer exception. | |
* | |
* @param p_function Function to be fired. | |
* @param args A list of parameters. | |
* | |
* @example | |
* <pre> | |
* import rinaldi.util.fire; | |
* | |
* const nullMethod : Function; | |
* | |
* // Fire the method "sum();" passing 5 and 5 as arguments | |
* fire(sum, 5, 5); | |
* | |
* function sum( p_a : Number, p_b : Number ) : void { | |
* trace(p_a + p_b); | |
* } | |
* | |
* // Nothing will be fired | |
* fire(nullMethod); | |
* </pre> | |
* | |
* @see rinaldi.util | |
* | |
* @date 23/08/2010 | |
* @author Rafael Rinaldi (rafaelrinaldi.com) | |
* | |
*/ | |
public function fire( p_function : Function, ...args ) : void | |
{ | |
if(p_function != null) p_function.apply(this, args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment