CheckBox in Flex4


 

CheckBox in Flex4

In Flex 4 the CheckBox Control is comprises from the components of both the MX and the Spark. We can use either MX CheckBox or Spark CheckBox both are same thing.

In Flex 4 the CheckBox Control is comprises from the components of both the MX and the Spark. We can use either MX CheckBox or Spark CheckBox both are same thing.

CheckBox in Flex4:

In Flex 4 the CheckBox Control is comprises from the components of both the MX and the Spark. We can use either MX CheckBox or Spark CheckBox both are same thing. Checkbox contains two part in a graphical shape. First one is label and second one is a small box which contain a checkmark or not. You can change the value of a  text label to a CheckBox control and place it to the left, right, up and down according to requirements. Checkbox contain two states first one is checked and second one is unchecked .The default value of Checkbox is unchecked. Checkbox value is true when it is checked and false when it is unchecked. The tag of checkbox control is <s:CheckBox>.....</s:CheckBox>. You can set the properties of checkbox with in the checkbox tag according to requirements.

Example:

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

<fx:Declarations>

<!-- Place non-visual elements (e.g., services, value objects) here -->

</fx:Declarations>

<fx:Script>

<![CDATA[

public function addtextarea():void

{

textarea1.text="";

if(chkBox1.selected == true) {

textarea1.text += "Checkbox1 is selected" + '\n' ;

}

if(chkBox2.selected == true) {

textarea1.text += "Checkbox2 is selected" + '\n';

}

if(chkBox3.selected == true) {

textarea1.text +="Checkbox3 is selected" + '\n';

}

}

]]>

</fx:Script>

<s:Panel title="CheckBox Control " x="117" y="87">

<mx:HBox>

<s:VGroup height="73">

<s:CheckBox id="chkBox1" label="CheckBox1" click="addtextarea()"/>

<s:CheckBox id="chkBox2" label="CheckBox2" click="addtextarea()"/>

0

<s:CheckBox id="chkBox3" label="CheckBox3" click="addtextarea()"/>

</s:VGroup>

<s:TextArea id="textarea1" height="73" width="208"/>

1

</mx:HBox>

</s:Panel>

</s:Application>

2

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

3

Ads