Re: [flexcoders] re-passing variable arguments?

2008-12-29 Thread Aaron Hardy

Try continueFunction.apply(args);

Aaron

toofah_gm wrote:


I have a method that accepts variable arguments like this:

public function doSomethingThenContinue(continueFunction:Function,
...args)
{
// execute some code that does important stuff

// call the continue function now that we are done passing the
original args to that function
continueFunction(args);
}

Is it possible to pass the variable arguments on to the generic
continueFunction in this manner? I don't really want the args to be
passed in a single Array, but want to call the continueFunction with
the arguments split out like this dynamically
continueFunction(args[0], args[1], etc.) depending on how many were
passed in and depending on how many parameters the continueFunction
accepts.

Is this possible to do somehow?

Thanks,

Gary

 




Re: [flexcoders] re-passing variable arguments?

2008-12-29 Thread Josh McDonald
What you're after is usually called a splat. It's not supported quite so
explicitly in AS3, but to do what you're after just use Function.apply(). So
in your case, it'd be:

continueFunction.apply(this, args);

-Josh

On Tue, Dec 30, 2008 at 8:58 AM, toofah_gm  wrote:

> I have a method that accepts variable arguments like this:
>
> public function doSomethingThenContinue(continueFunction:Function,
> ...args)
> {
>   // execute some code that does important stuff
>
>   // call the continue function now that we are done passing the
> original args to that function
>   continueFunction(args);
> }
>
> Is it possible to pass the variable arguments on to the generic
> continueFunction in this manner?  I don't really want the args to be
> passed in a single Array, but want to call the continueFunction with
> the arguments split out like this dynamically
> continueFunction(args[0], args[1], etc.) depending on how many were
> passed in and depending on how many parameters the continueFunction
> accepts.
>
> Is this possible to do somehow?
>
> Thanks,
>
> Gary
>
>
> 
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>


-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Like the cut of my jib? Check out my Flex blog!

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: j...@gfunk007.com
:: http://flex.joshmcdonald.info/
:: http://twitter.com/sophistifunk


Re: [flexcoders] re-passing variable arguments?

2008-12-29 Thread Manish Jethani
On Tue, Dec 30, 2008 at 4:28 AM, toofah_gm  wrote:
> I have a method that accepts variable arguments like this:
>
> public function doSomethingThenContinue(continueFunction:Function,
> ...args)
> {
>   // execute some code that does important stuff
>
>   // call the continue function now that we are done passing the
> original args to that function
>   continueFunction(args);
> }
>
> Is it possible to pass the variable arguments on to the generic
> continueFunction in this manner?  I don't really want the args to be
> passed in a single Array, but want to call the continueFunction with
> the arguments split out like this dynamically
> continueFunction(args[0], args[1], etc.) depending on how many were
> passed in and depending on how many parameters the continueFunction
> accepts.

  continueFunction.apply(this, args);

Manish

-- 
http://manishjethani.com


Re: [flexcoders] re-passing variable arguments?

2008-12-29 Thread Maciek Sakrejda
Yes, through the magic of higher-order functions:
http://livedocs.adobe.com/flex/3/langref/Function.html#apply()

-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-Original Message-
From: toofah_gm 
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com
Subject: [flexcoders] re-passing variable arguments?
Date: Mon, 29 Dec 2008 22:58:14 -

pass the variable arguments on to the generic 
continueFunction in this manner? I don't really want the args to be 
passed in a single Array, but want to call the continueFunction with 
the arguments split out like this dynamically 
continueFunction(args[0],




[flexcoders] re-passing variable arguments?

2008-12-29 Thread toofah_gm
I have a method that accepts variable arguments like this:

public function doSomethingThenContinue(continueFunction:Function, 
...args)
{
   // execute some code that does important stuff

   // call the continue function now that we are done passing the 
original args to that function
   continueFunction(args);
}

Is it possible to pass the variable arguments on to the generic 
continueFunction in this manner?  I don't really want the args to be 
passed in a single Array, but want to call the continueFunction with 
the arguments split out like this dynamically 
continueFunction(args[0], args[1], etc.) depending on how many were 
passed in and depending on how many parameters the continueFunction 
accepts.

Is this possible to do somehow?

Thanks,

Gary