欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Flex中禁用Combobox的可编辑属性和添加prompt属性

程序员文章站 2022-03-02 13:33:54
...

Flex中禁用Combobox的可编辑属性和添加prompt属性

Flex中可以选择使用Dropdownlist或者Combobox来实现一些下拉列表的功能,通过本实例,Dropdownlist和Combobox基本上实现了同等功能转换

Combobox禁用了inputtext的可编辑属性。闲言碎语不要讲,我有代码来呈上!

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" viewSourceURL="srcview/index.html">
 
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent;
 
            import spark.events.DropDownEvent;
 
            private var arr:Array=[{label:"Red"},{label:"Orange"},{label:"Yellow"},{label:"Blue"},{label:"Green"}];
            [Bindable]
            private var myData:ArrayCollection=new ArrayCollection(arr);
 
            protected function combobox1_creationCompleteHandler(event:FlexEvent):void
            {
                this.cb.textInput.text="Please Select";
            }
 
            protected function cb_closeHandler(event:DropDownEvent):void
            {
                this.cb.setStyle("skinClass",undefined);
            }
 
        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
    </s:layout>
    <s:ComboBox id="cb" skinClass="com.MyComboBox" dataProvider="{myData}"
                creationComplete="combobox1_creationCompleteHandler(event)" close="cb_closeHandler(event)"/>
 
</s:Application>