Methods | Properties | Effects | Events | Styles | Examples Frames | No Frames

mx.controls
Class CheckBox

Inheritance ImageInheritance ImageInheritance ImageInheritance Image


class CheckBox
extends mx.controls.Button

The CheckBox control is commonly used graphical control that can contain a check mark or be unchecked (empty). CheckBox controls gather a set of true or false values that are not mutually exclusive. You can add a text label to a CheckBox control and place it to the left, right, top, or bottom. When a user clicks a CheckBox control or its associated text, the CheckBox control changes its state, from checked to unchecked, or from unchecked to checked.

MXML Syntax

The <mx:CheckBox> tag inherits all the properties of its parent classes, and the following properties:

 <mx:CheckBox
label="No default."
labelPlacement="right|left|bottom|top"
selected="false|true"
click="Event handler; no default."
/>

Click here to view the Examples

Methods

Methods inherited from class mx.core.UIComponent
drawFocus   getFocus   getFocusManager   setEnabled   setFocus  

Methods inherited from class mx.core.UIObject
addEventListener   applyProperties   buildDepthTable   commitProperties   constructObject2   createAccessibilityImplementation   createChildAtDepth   createChildren   createClassChildAtDepth   createClassObject   createEmptyObject   destroyObject   dispatchEvent   doLater   draw   drawRect   executeBindings   fillRect   findNextAvailableDepth   getRepeaterItem   getStyle   handleEvent   init   invalidate   invalidateLayout   invalidateProperties   invalidateSize   invalidateStyle   layoutChildren   measure   move   redraw   removeEventListener   setDepthAbove   setDepthBelow   setMask   setSize   setSizeNoLayout   setStyle   swapDepths  



Properties
       label: String
Text label for the control.
       labelPlacement: String
Orientation of the label.
       selected: Boolean
If true, the check box is checked.
staticversion: String
Version string for this class.

Properties inherited from class mx.controls.Button
icon   label   labelPlacement   version  

Properties inherited from class mx.controls.SimpleButton
falseDisabledSkin   falseDownSkin   falseOverSkin   falseUpSkin   selected   toggle   trueDisabledSkin   trueDownSkin   trueOverSkin   trueUpSkin   version  

Properties inherited from class mx.core.UIComponent
enabled   errorString   tabEnabled   tabIndex   version  

Properties inherited from class mx.core.UIObject
alpha   baselinePosition   className   depth   documentDescriptor   height   heightFlex   id   instanceIndices   isDocument   kStretch   layoutHeight   layoutWidth   maxHeight   maxWidth   minHeight   minWidth   mouseX   mouseY   nestLevel   oldHeight   oldWidth   oldX   oldY   parent   parentApplication   parentDocument   percentHeight   percentWidth   preferredHeight   preferredWidth   repeaterIndices   scaleX   scaleY   styleName   tabEnabled   toolTip   version   visible   width   widthFlex   x   y  



Effects

Effects inherited from class mx.core.UIComponent
focusInEffect   focusOutEffect  

Effects inherited from class mx.core.UIObject
creationCompleteEffect   hideEffect   mouseDownEffect   mouseOutEffect   mouseOverEffect   mouseUpEffect   moveEffect   resizeEffect   showEffect  



Events
clickBroadcast when the user selects the control. The target property of the event object contains a reference to the component that triggered the event. The type property of the event object contains the name of the event, click.

Events inherited from class: mx.controls.Button
click 

Events inherited from class: mx.controls.SimpleButton
buttonDown  buttonDragOut  click 

Events inherited from class: mx.core.UIComponent
focusIn  focusOut  invalid  keyDown  keyUp  valid  valueCommitted 

Events inherited from class: mx.core.UIObject
creationComplete  dragComplete  dragDrop  dragEnter  dragExit  dragOver  draw  effectEnd  effectStart  hide  hideToolTip  initialize  load  mouseChangeSomewhere  mouseDown  mouseDownSomewhere  mouseMove  mouseMoveSomewhere  mouseOut  mouseOver  mouseUp  mouseUpSomewhere  move  resize  show  showToolTip  unload 



Styles

Styles inherited from class mx.controls.Button
borderThickness   cornerRadius   horizontalGap   textRollOverColor   textSelectedColor   verticalGap  

Styles inherited from class mx.controls.SimpleButton
repeatDelay   repeatInterval  

Styles inherited from class mx.core.UIComponent
backgroundAlpha   backgroundColor   backgroundDisabledColor   backgroundImage   backgroundSize   barColor   borderCapColor   borderColor   borderSides   borderStyle   borderThickness   cornerRadius   disabledColor   dropShadow   errorColor   fillColors   highlightColor   modalTransparency   scrollTrackColor   selectedFillColors   shadowCapColor   shadowColor   shadowDirection   shadowDistance   symbolBackgroundColor   symbolBackgroundDisabledColor   symbolBackgroundPressedColor   symbolColor   symbolDisabledColor   themeColor  

Styles inherited from class mx.core.UIObject
color   fontFamily   fontSize   fontStyle   fontWeight   horizontalGap   leading   marginLeft   marginRight   textAlign   textDecoration   textIndent   verticalGap  



Property Detail

label

label: String  

Text label for the control. By default, the label appears centered within the control.


labelPlacement

labelPlacement: String  

Orientation of the label. Possible values are right, left, bottom, and top. The default is right.


selected

selected: Boolean  

If true, the check box is checked. If false, the check box is not checked. The default value is false.


version

static  version: String  

Version string for this class.


Examples
CheckBoxExample.mxml
<?xml version="1.0"?>
<!-- Simple example to demonstrate the CheckBox control -->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" backgroundColor="#FFFFFF">

    <mx:Panel title="CheckBox Panel" marginTop="10">

        <mx:Script>
         
           // This function adds and deletes items from the shopping cart.
           function modifyCart()
           {
            	cartItems.text = "";
	    	
	    	if(milkCB.selected == true)
	    	{
	    	  
	    	  cartItems.text += "milk" + newline ;
	    	}
	   	
	   	if(eggsCB.selected == true)
	    	{
	    	  cartItems.text += "eggs" + newline;
	    	}
	    	
	    	if(breadCB.selected == true)
	    	{ 
	    	  cartItems.text +="bread" + newline;
	    	}
      	   }
      	   
           // This Function brings up Alert pop-ups
	   function sendMessage()
	   {
	        if(couponCB.selected == true)
		{
		  alert(' You will receive coupons to increase your savings');
		}
		else
		{
		alert(' You will not receive any coupons ');
		}
	   }
	   
        </mx:Script>

        <mx:HBox>

            <mx:VBox>

                <mx:CheckBox id="milkCB" label="milk" click="modifyCart()"/>
                <mx:CheckBox id="eggsCB" label="eggs" click="modifyCart()"/>
                <mx:CheckBox id="breadCB" label="bread" click="modifyCart()"/>

            </mx:VBox>

            <mx:VBox>

                <mx:Label text="Items in my cart "/>
                <mx:TextArea id="cartItems" width="300" height="50" vScrollPolicy="off"/>
                <!-- Event handler sendMessages() is used to handle event click -->
                <mx:CheckBox id="couponCB" label="Send me coupons for items in my cart" click="sendMessage()" selected="true" color="blue"/>

            </mx:VBox>

        </mx:HBox>

    </mx:Panel>

</mx:Application>




 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/asdocs_en/mx/controls/CheckBox.html