Re: [flexcoders] How to overload methods in Actionscript?

2005-09-17 Thread Manish Jethani
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/
 





[flexcoders] How to overload methods in Actionscript?

2005-09-15 Thread Libby
When I use same method name more than once (with additional
arguments), Flex compiler says I can't use the same name more than
once. Is this really true (Flex doesn't support method overloading?)
or do I need to do something different?

Thanks,
Libby





 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/
 




Re: [flexcoders] How to overload methods in Actionscript?

2005-09-15 Thread Stanislav Zayarsky
Libby,

ActionScript doesn't support method overloading.

Best regards
Stanislav

On 9/15/05, Libby [EMAIL PROTECTED] wrote:
 When I use same method name more than once (with additional
 arguments), Flex compiler says I can't use the same name more than
 once. Is this really true (Flex doesn't support method overloading?)
 or do I need to do something different?
 
 Thanks,
 Libby
 
 
 
 
 
 
 --
 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
 
 
 
 
 
 



 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/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/
 





RE: [flexcoders] How to overload methods in Actionscript?

2005-09-15 Thread Abdul Qabiz
Hi,

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]);
}   
}

//usage:

sayHello();

sayHello(Abdul);

sayHello(Abdul, Qabiz);


You can access individual argument using arguments array. You can use
typeof and instanceof to find the type of each argument and have a
switch logic to perform different algorithm for different set of
arguments.


Does that make sense?

-abdul

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Libby
Sent: Thursday, September 15, 2005 7:09 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] How to overload methods in Actionscript?

When I use same method name more than once (with additional
arguments), Flex compiler says I can't use the same name more than
once. Is this really true (Flex doesn't support method overloading?)
or do I need to do something different?

Thanks,
Libby






--
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



 




 Yahoo! Groups Sponsor ~-- 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/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/