Reputation: 3368
I was wondering i can call an as3 function defined in script from mxml code just like this:
<mx:Line x="translateX(xmin);" .. >
<mx:Script>
<![CDATA[
// do some basic math
private function translate ...
If not possible do i have to convert everything to as3 ?
Thanks
Upvotes: 1
Views: 718
Reputation: 17734
You can but a straight-up function call like that needs to go into an event attribute in MXML, i.e. "when this event is dispatched, invoke this function." The classic example being:
<mx:Button label="Hello" click="myFunction()"/>
You can use a function as you have illustrated above provided that it's in a binding expression and the arguments passed to the function are bindable:
<mx:Line x="{positionLine(xmin)}"/>
// defined somewhere in a mx:Script block
[Bindable] private var xmin : Number;
Upvotes: 5