Passing unlimited arguments to a function

I recently stumbled across Flash Extensions which specializes in Flash Training & Solutions. There I found a few video tutorials and thats where this comes from 😉

Here’s how you can pass unlimited arguments to a function. 🙂 Flex Developers from the C++ and Java worlds might be familiar with this. Yet, this could be new stuff for some. The most common method used to pass multiple arguments to a function where the number of arguments are not predefined is to pass the arguments as a complex object like Array or something.

private function normalUsage(list:Array):void{":"));

The other better way to handle this is something like this. Use “…args” in the function and then you can pass any number of arguments. –

private function dataToPop():void{

private function newUsage(...args):void{":"));

Try it out. This could be useful at many places. 😉


3 Responses to Passing unlimited arguments to a function

  1. thanks for the info im is very use full to my study

  2. Thanks in advance. I am using the ..args to send multiple arguments to a netConnection class (AMFPHP usage). My problem is how I can pass those args to another function like:

    public function joupConnection(method:String, result:Function, status:Function, …args)
    res = new Responder(result, status);‘joup.’ + method, res, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]);

    Like this is working but this is not good especially if you have more than 10 args.

    Any ideas?

  3. Kenny says:


    You are looking for the apply() method.


    public function ProxyDelegate(…args)

    var _service:NetConnection = new NetConnection();
    var _responder:Responder = new Responder(onResult, onFault);


    args.unshift(“YourPhpClass.yourPhpMethod”, _responder);, args);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: