damn, should be:

o[ method ].apply( o, ... args... );


Long day...

~neo


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of neo binedell
Sent: 29 June 2006 10:42 PM
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] trying to call a function passed as an argument

Try something like this:

...
doFirst( "hello", "world", bar, "doLast" ); ...
 
public function doFirst( aS:String, bS:String, o:Object, m:String ) {
    trace("the first string is "+aString);

    // call the second function here ???
   a[ method ].apply( a, ... args... );
}

~neo

ps:
Interestingly enough addEventListener in AS3 does what your code wants to do
implicitly ;p

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Elie
Zananiri
Sent: 29 June 2006 09:22 PM
To: flashcoders@chattyfig.figleaf.com
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(??);
  }
}
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

Reply via email to