我正在使用cs3组合框控件。我希望提示“选择一个城市”保持不变,但只要您在列表中选择一个项目,它就会消失。有谁知道如何解决这个问题?
谢谢!
public class ComboSkin extends Sprite
{
private var _cboCities:ComboBox = new ComboBox();
public function ComboSkin()
{
init();
}
private function init():void
{
_cboCities.y = 30;
_cboCities.setSize(100, 15);
_cboCities.prompt = "Select a City";
var items:Array = [
{label:"San Francisco", data:"601 Townsend St."},
{label:"San Jose", data:"345 Park Ave."},
{label:"San Diego", data:"10590 West Ocean Air Drive, Suite 100"},
{label:"Santa Rosa", data:"2235 Mercury Way, Suite 105"},
{label:"San Luis Obispo", data:"3220 South Higuera Street, Suite 311"}
];
_cboCities.dataProvider = new DataProvider(items);
var tf:TextFormat;// = new TextFormat();
tf = new TextFormat("Arial", 8, 0x000000);
_cboCities.textField.height = 10;
_cboCities.textField.setStyle("textFormat", tf);
addChild(_cboCities);
}
}
}
答案 0 :(得分:0)
选择下拉列表后,只需将selectedItem保存在您自己的类中,然后将数据提供者重新分配给组件,它将覆盖所有数据,并且提示应该再次可见。
var selectedCity = null;
_cboCities.y = 30;
_cboCities.setSize(100,30);
_cboCities.prompt =“选择一个城市”;
var items:Array = [ {label:"San Francisco", data:"601 Townsend St."}, {label:"San Jose", data:"345 Park Ave."}, {label:"San Diego", data:"10590 West Ocean Air Drive,Suite 100"}, {label:"Santa Rosa", data:"2235 Mercury Way, Suite 105"}, {label:"San Luis Obispo", data:"3220 South Higuera Street,Suite 311"} ]; _cboCities.dataProvider = new DataProvider(items); _cboCities.addEventListener(SliderEvent.CHANGE, function():void{ selectedCity = items[_cboCities.selectedIndex].label; trace(selectedCity) _cboCities.dataProvider = new DataProvider(items); })