



The other day I wanted to create a function in a class that would take a Function as a parameter and an Array of arguments. Much like callLater() does, but not doing the whole queuing thing until the next frame.
So how do you call a function that may have any number of arguments. Well here is the code and it should speak for itself.
protected function checkSomethingThenCallOtherFunction( method : Function, args : Array = null ) : void { if( something.length < someMaxLimit ) { method.apply( null, args ); } else { //do something else } }
So how easy is that? Pass in the function and an array of arguments, that’s all.






More Options ...
Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 