Showing posts with label radio script. Show all posts
Showing posts with label radio script. Show all posts

Monday, August 16, 2010

Flex Framework Radio Button with ActionScript


Flex Framework Radio Button with ActionScript

Aim:
A radio button or option button is a type of graphical user interface element that allows the user to choose only one of a predefined set of choices.

Problem:

Already from previous post, we can understand how to create radio button. Now how to get selected radio button values .

Procedure:

Step 1:

Create project if you don’t have project. Revise the previous post how to create project.

Step 2:

            Create file such as RadioButton.mxml

            Including following coding into the RadioButton.mxml


< ?xml version = '1.0' encoding = 'utf-8'? >
< mx:Application xmlns:mx = 'http://www.adobe.com/2006/mxml' >
< mx:Script >

private function display(event:Event):void
{

if(r1.selected)
{
count.text="Male";
}
if(r2.selected)
{
count.text="Female";
}
}


< /mx:Script >

< mx:Panel title="ComboBox and Radio Button" height="500" width="500" layout="vertical" >
< mx:Label id="count"/ >

< mx:RadioButtonGroup id="rad"/ >

< mx:RadioButton id="r1" label="Male" group="{rad}"/ >

< mx:RadioButton id="r2" label="Female" group="{rad}"/ >

< mx:Button label="OK" click="display(event);"/ >

< /mx:Panel >

< /mx:Application >


Step 3:

Include following coding into the build.xml

< project name='Flex' default='mxml' >

< target name='mxml' >
< property name='compiler' location='E:\InstalledSoftware\FlexSoft\bin\mxmlc.exe' / >

< exec executable='${compiler}' failonerror='true' >
< arg line='-output F:\FLEXWORKSPACE\FlexExample\ComboScript.swf'/ >
< arg line='F:\FLEXWORKSPACE\FlexExample\ComboScript.mxml' / >
< /exec >

< echo > mxml file compiled successfully < /echo >
< echo > swf file generated successfully < /echo >

< /target >


< /project >


Step 4:

Run the Application.


Step 5:

Ouput display














If you select Male, the Male ouput is displayed in the Label Button.