Wednesday, May 4, 2011

Find out args length of a function

Here is a sample program to get the number of arguments that a function takes.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
creationComplete="initAPP()">

<mx:Script>
<![CDATA[

private function initAPP(one:int=0, obj:Object=null):void {
}

private function showFunctionArgumentsLength():void {
trace("Length: "+ (initAPP as Function).length)
}

]]>
</mx:Script>

<mx:Button label="Check" click="showFunctionArgumentsLength()" />

</mx:Application>



Note: This will give you all the arguments length, not only required params.


No comments:

Post a Comment