One MXML document (function call in MXML tag event)

The logic for the function is inside an <mx:Script> block in the MXML document, and is called from the MXML tag's click event, as the following code shows:

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">

<mx:Script>
      <![CDATA[
         function calculate() {
            celsius.text=(farenheit.text-32)/1.8;
         }
   ]]>
</mx:Script>
   <mx:Panel title="My Application" marginTop="10" marginBottom="10"
      marginLeft="10" marginRight="10" >

      <mx:HBox>
         <mx:Label text="Temperature in Farenheit:"/>
         <mx:TextInput id="farenheit" width="120"/>
         <mx:Button label="Convert" click="calculate();" />
         <mx:Label text="Temperature in Celsius:"/>
         <mx:Label id="celsius" width="120" fontSize="48"/>
      </mx:HBox>
   </mx:Panel>
</mx:Application>

Version 1.5

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000071.htm