:) nice question gets nice answer! 
here it is.. 

        var target:* = Application.application; 
        var methodName:String = "getChildren"; 
        var type:XML = flash.utils.describeType(target); 
        var paramLength:int = type.method.(@name ==
methodName).parameter.length(); 
        var f:Function = function(...args):* 
        { 
                var tmp:Array = args; 
                tmp.length = paramLength; 
                return target[methodName].apply(target, tmp); 
        }; 
        Alert.show(f("a", 1, 2, 3)); 



ganesh-16 wrote:
> 
> 
> Thanks Devaraj for the overloading information. But the context is
> different here. I can't change the existing functions assigned for
> datatTipFunction which can be taking two or one argument. I just want
> to introspect the function to know how many number of arguments.
> Please see my earlier comments (reply to venkat).
> 
> On Jan 31, 4:56 pm, Devaraj <[email protected]> wrote:
>> Hi,
>> I have achieved function overloading using "...args" and Dictionary on
>> the below
>> linkhttp://nsdevaraj.wordpress.com/2008/06/24/as3-function-overloading/
>>
>> Regards,
>> Devaraj
>>
>> On Jan 31, 12:49 pm, Venkat Viswanathan <[email protected]> wrote:
>>
>>
>>
>> > Hi,
>>
>> > I am not sure how you are going to use this functionality with AS3.0.
>> > Firstly AS3 does not support method overloading... so the case of
>> having two
>> > or more methods with same name and different number of parameters is
>> out of
>> > question. And if you are going to make a function call, and there is an
>> > argument count mismatch, you will get a compile-time error. The only
>> > possible way I see to solution to this problem (may not be applicable
>> in
>> > your case), is to have f2 that take any number of parameters using
>> "...args"
>> > and then from f1() pass any number of parameters.
>>
>> > If this does not apply in your case, can you explain us where you are
>> going
>> > to use this functionality. There has to be some workaround to this
>> issue.
>>
>> > Regards,
>> > Venkatwww.venkatv.com
>>
>> > On Sat, Jan 31, 2009 at 12:01 PM, ganesh <[email protected]>
>> wrote:
>>
>> > > Thanks a lot for the quick reply. I expected this reply!!
>> > > This works fine if you are inside the function. But if you want to
>> > > call another function say we are trying to call function f2 in
>> > > function f1. I don't know how many parameters f2 takes, it varies.
>> > > then how to introspect the function f2 to call it with proper number
>> > > of parameters?
>>
>> > > On Jan 30, 6:05 pm, "v...@t" <[email protected]> wrote:
>> > > > hello,
>>
>> > > > Try to use arguments.length.
>>
>> > > > like .....
>>
>> > > >            privatefunctiontest(str:String,count:int):void
>> > > >            {
>> > > >                    trace ( arguments.length );  // return number of
>> > > parameter
>> > > > thisfunctiontake = 2
>> > > >            }
>>
>> > > > may help.
>>
>> > > > Thanks
>> > > > VIrat Patel
>>
>> > > > On Jan 30, 5:30 pm, ganesh <[email protected]> wrote:
>>
>> > > > > Hello All,
>> > > > >           I want to call afunction. I just want to know how many
>> > > > >parametersthatfunctiontakes? Is there any API available to get a
>> > > > > count of number of arguments afunctiontakes?
>> > > > > Thanks.- Hide quoted text -
>>
>> > > > - Show quoted text -- Hide quoted text -
>>
>> - Show quoted text -
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-flex_india%3A18745--How-to-find-number-of-parameters-a-function-takes--tp21746312p22164779.html
Sent from the Flex India mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to