<?xml version="1.0"?> 红字部分是你对该控件的多个属性进行赋值的写法。
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
<mx:Script>
<![CDATA[
// Import the Checkbox class.
import mx.controls.CheckBox;
// Define a variable to hold the new CheckBox control.
var addedCheckBox:CheckBox;
// Define a variable to track if you created a CheckBox control.
var checkBoxCreated:Boolean = false;
function addCB()
{
// Test to see if you have already created the CheckBox control.
if(checkBoxCreated==false)
{
addedCheckBox = CheckBox(myHB.createChild(CheckBox, undefined, {label:"New CheckBox",toolTip:"test"}));
checkBoxCreated=true;
}
}
function delCB()
{
// Make sure a CheckBox control exists.
if(checkBoxCreated==true)
{
myHB.destroyChild(addedCheckBox);
checkBoxCreated=false;
}
}
]]>
</mx:Script>
<mx:VBox >
<mx:HBox id="myHB" borderStyle="solid" />
<mx:Button label="add CheckBox" click="addCB()" />
<mx:Button label="remove CheckBox" click="delCB()" />
</mx:VBox>
</mx:Application>