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
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)
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
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
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
5 matches
Mail list logo