Call your method in Button click event : Button « Components « Flex






Call your method in Button click event

Call your method in Button click event
    
<?xml version="1.0" encoding="UTF-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    
    private function calculateFactorial(n:String):String
    {
        var y:Number=1;
        for (var x:Number = 1;x <= Number(n); x++) {
            y = y * x;
        }
        return String(y);
    }
  
    </mx:Script>
    <mx:Panel title="Calculate Factorial">
        <mx:HBox>
            <mx:Label text="Input:"/>
            <mx:TextInput id="textArea1" text="1"/>
            <mx:Button id="button1" label="Calculate" click="result.text=calculateFactorial(textArea1.text)"/>
        </mx:HBox>
        <mx:HBox>
            <mx:Label text="Factorial:"/>
            <mx:Label id="result"/>
        </mx:HBox>
    </mx:Panel>
</mx:Application>

   
    
    
    
  








Related examples in the same category

1.Making use of the Grid containerMaking use of the Grid container
2.Set Button iconSet Button icon
3.Handle Button click eventHandle Button click event
4.Set Button Label and Font sizeSet Button Label and Font size
5.Custom Button StyleCustom Button Style
6.Use CSS to set Button fade effectUse CSS to set Button fade effect
7.Change Button labelChange Button label
8.Remove a button from the application when the user presses itRemove a button from the application when the user presses it