The function call is in an MXML tag event, and the function is defined in a separate ActionScript file, as the following code shows:
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> <!-- Specify the ActionScript file containing the function. --><mx:Script source="sample3script.as"/><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>
The sample3script.as ActionScript file contains the following code:
function calculate() {
celsius.text=(farenheit.text-32)/1.8;
}
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/00000072.htm