**3.0** FLASH組件應用

一、單選按鈕。
         用代碼創建。
        
//------------------------------------------------
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;

var myRadioGroup:RadioButtonGroup = new RadioButtonGroup("options");
myRadioGroup.addEventListener(Event.CHANGE, changeHandler_Radio);
var Order:String ="";
var radio1:RadioButton = new RadioButton();
radio1.label = "A-Z";
radio1.value = "1";
radio1.group = myRadioGroup;
radio1.move(142, 63);
addChild(radio1);

var radio2:RadioButton = new RadioButton();
radio2.label = "Z-A";
radio2.value = "2";
radio2.group = myRadioGroup;
radio2.move(228, 63);
addChild(radio2);

var radio3:RadioButton = new RadioButton();
radio3.label = "Date(Newest)";
radio3.value = "3";
radio3.group = myRadioGroup;
radio3.move(324, 63);
addChild(radio3);

function changeHandler_Radio(event:Event):void {
        var rbg:RadioButtonGroup = event.target as RadioButtonGroup;
        if (rbg.selectedData != null) {
    Order=rbg.selectedData.toString();
            trace(Order);
        } else {
                trace("no value specified.");
        }
}
 
二、組件事先在場景中排好。
import fl.controls.RadioButtonGroup;

var myRadioGroup:RadioButtonGroup = new RadioButtonGroup("options");
myRadioGroup.addEventListener(Event.CHANGE, changeHandler);

a.group = myRadioGroup;
b.group = myRadioGroup;

function changeHandler(event:Event):void {
        var rbg:RadioButtonGroup = event.target as RadioButtonGroup;
        if (rbg.selectedData != null) {
                trace(rbg.selectedData);
        } else {
                trace("no value specified.");
        }
}
 
三、下拉框。
import fl.containers.ScrollPane;

var myComboBox:ComboBox = new ComboBox();
myComboBox.width = 120;
myComboBox.move(146, 12);
myComboBox.editable = false;

addChild(myComboBox);
myComboBox.addItem({label:"-- Select --",data:""});
//以下可以用循環將某數組中的數據添加入組件。
myComboBox.addItem({label:CateList.Name,data:CateList.Value});
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章