This is how I do it:
var functA:Function = function(){
trace("A");
}
var functB:Function = function(){
trace("B");
}
function performFunctions(funct:Function){
funct();
}
performFunctions(functA);
performFunctions(functB);
Doug Coning
Senior Web Development Programmer
FORUM Solutions, LLC
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of Elie Zananiri
> Sent: Thursday, June 29, 2006 3:22 PM
> To: [email protected]
> Subject: [Flashcoders] trying to call a function passed as an argument
>
> Hi all,
>
> I have this method where I need to call a function passed as an
argument
> (kind of like in setInterval()) and I don't understand the
documentation
> and
> can't get it to work.
>
> First of all, I don't understand how to pass the function as a
parameter.
> Am I passing a String or an actual Function object? Can I pass a
Function
> with parameters? Do I have to write the parentheses in the parameter?
>
> Next, how do I call this function? The Function.call() function
requires
> a
> parameter but I don't get what it does...
>
> Thanks for the help!
>
> -Elie
>
> Here is the structure I have:
>
> class Bar {
> public Bar() {
> }
>
> public function doLast(bString:String) {
> trace("the second string is "+bString);
> }
> }
>
> class Foo {
> var bar:Bar;
>
> public Foo() {
> bar = new Bar();
> doFirst("hello", "world", bar.doLast);
> }
>
> public function doFirst(aString:String, bString:String,
> aFunction:Function) {
> trace("the first string is "+aString);
>
> // call the second function here ???
> aFunction.call(??);
> }
> }
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com