On 9/15/05, Abdul Qabiz <[EMAIL PROTECTED]> wrote:

> ActionScript doesn't support method overloading. Instead you can use
> following approach.
> 
> 
> function sayHello()
> {
>         var n:Number = arguments.length;
> 
>         if(n==0)
>         {
>                 alert("Hello World");
>         }
>         else if(n==1)
>         {
>                 alert("Hello " + arguments[0]);
>         }
>         else if(n==2)
>         {
>                 alert("Hello " + arguments[0] + " " + arguments[1]);
>         }
> }

Well I would prefer default arguments instead.

function split(s:String, delim:String):Array
{
  if (delim == undefined)
    delim = " "; // default to space character

  ...
}

So you can pass one or two arguments to the split function.  That's
method overloading.  You can also type one of your arguments as Object
and then check the type inside the function using the instanceof
operator.  That's more method overloading. :)  But no true method
overloading as in Java or C++.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to