Mxml and as3 confusion [simple]

I was wondering if I can call the as3 function defined in the script from the mxml code like so:

<mx:Line x="translateX(xmin);" .. >


<mx:Script>
   <![CDATA[

   // do some basic math
   private function translate ...

      

If this is not possible, do I need to convert everything to as3?

thank

+1


source to share


1 answer


You can, but a direct task call like this must go into the event attribute in MXML, that is, "when this event dispatched, call this function." A classic example:

<mx:Button label="Hello" click="myFunction()"/>

      



You can use a function as shown above, provided it is in the 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;

      

+5


source







All Articles