You can't pass a reference to a method call like you seem to be trying to do by
'bar.doLast'. You *can* pass functions around, but not object methods -- they
no longer know what object they are supposed to act on.
See:
var a:Array = [1, 2, 3];
a.shift(); // a = [2, 3];
var shiftMethod:Function
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:
Interesting
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 funct
if the function-param in
public function doFirst(aString:String, bString:String,
aFunction:Function)
is a good reference to an existing function
you don't need to use the call()
to execute aFunction you can just use
public function doFirst(aString:String, bString:String,aFunction:Function)
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 Programm
5 matches
Mail list logo