> ..to the object class. Further, at the point where the callback
> object should fire, I've added this code:
>
> if( callback != null )
> callback( 3 );
>
do you ever get here? In case you don't know: you can set breakpoints
when using FlexBuilder. There trace(string) function is also handy for
debugging?
I've tried this code and it works as expected, what are you doing different?
FooClass.as:
====
package {
public class FooClass {
public var Callback :Function = null;
public function Fire() :void {
if (Callback != null) {
Callback(42);
}
}
}
}
====
app.mxml:
====
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="OnCreationComplete()">
<mx:Script>
<![CDATA[
private var _fooClass :FooClass = new FooClass();
public function OnCreationComplete() :void {
_fooClass.Callback = menuSelect;
testButton.addEventListener(MouseEvent.CLICK,
OnTestButtonClick);
}
private function menuSelect(index :int) :void {
trace(index);
}
private function OnTestButtonClick(event :Event) :void {
_fooClass.Fire();
}
]]>
</mx:Script>
<mx:Canvas id="container" horizontalScrollPolicy="off"
verticalScrollPolicy="off" width="640" height="480" backgroundColor="red">
<mx:Button id="testButton">
</mx:Button>
</mx:Canvas>
</mx:Application>
====
hth
Ben