Get input from TextInput, Do calculation and assign result to Label
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="foo()">
<mx:Script>
[Bindable]
private var answer:String;
private function foo () : Function {
var x:int = int(ti1.text);
function rectArea(y:int) : int {
return x * y
}
return rectArea;
}
private function bar () : void {
var myProduct:Function = foo();
answer = myProduct(int(ti2.text));
}
</mx:Script>
<mx:Form>
<mx:FormItem label="X">
<mx:TextInput id="ti1" text="10" />
</mx:FormItem>
<mx:FormItem label="Y">
<mx:TextInput id="ti2" text="20" />
</mx:FormItem>
<mx:Label id="label1" text="{answer}" />
</mx:Form>
<mx:Button id='b1' label="X * Y" click="bar()" />
</mx:Application>
Related examples in the same category