新闻频道
动态生成组件
时间:2008-6-23 15:12:11 来源:银河网 作者: 编辑:

<?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>

  红字部分是你对该控件的多个属性进行赋值的写法。

新闻搜索

标题:

编辑推荐
暂时没有记录
相关文章