It looks like you can't use Function() as a cast operator. I'm not sure
whether this is an AS3 compiler bug or not. Instead of
Function(call.callbck).call(this);
try
(call.callbck as Function).call(this);
or simply
call.callbck.call(this);
- Gordon
________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of vijay95052
Sent: Wednesday, April 11, 2007 7:45 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] as3 - accepting a callback function name as input
parameter to a function
hi all,
I am implementing a actionscript function that takes in a function
name as parameter. I want to use the passed in parameter as a
callback function, just like mx:application creationComplete() does.
I am not able to get it to work.
In my MXML, I have:
<mx:Script>
<![CDATA[
public function initApp()
{
initApp2(initializeChart);
}
public function initializeChart()
{
....
}
]]>
</mx:Script>
In another actionscript util class, I have:
public function initApp2(callbck:Function):void
{
var service:HTTPService = new HTTPService();
service.url = chrtdefurl;
service.addEventListener(ResultEvent.RESULT, chartDefLoaded);
var call:Object = service.send();
call.callbck = callbck;
}
public function chartDefLoaded(event:ResultEvent):void
{
chartDefXML = new XML(event.result);
var call:Object = event.token;
Function(call.callbck).call(this);
}
I get error:
EvalError: Error #1066: The form function('function body') is not
supported.
at simpleline2/chartDefLoaded()
Any ideas?
Thanks
vijay