Flex

关注公众号 jb51net

关闭
首页 > 网页制作 > Flash > Flex > Flex 文本框

Flex 文本框的输入下拉提示

作者:

在很多时候我们要实现一个输入,显示提示并且可以从提示选择的功能,这是一种基于ComboBox 的变相实现,从服务器上动态获取
复制代码 代码如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:FormItem xmlns:mx="http://www.adobe.com/2006/mxml" label="" required="true" width="305" fontWeight="bold" height="28" horizontalAlign="right" textAlign="center" fontStyle="normal">

        <mx:Script>
        <!--[CDATA[            
            import mx.managers.PopUpManager;
            import mx.controls.Text;
            import mx.rpc.events.ResultEvent;
            import Scripts.ToolHelper;        

            //public var _win:PortWindow=new PortWindow();
            [Bindable]
            private var PortName:Text=new Text();

            private function DropPorts_KeyDown(event:KeyboardEvent):void
                {                    
                    if(this.DropPorts.editable==false)return;
                    this.DropPorts.close();
                    if(event.keyCode==Keyboard.ENTER)
                    {    
                        this.DropPorts.prompt=this.DropPorts.text;
                        if(this.DropPorts.text.length<2)return;
                        this.HttpPort.cancel();
                        this.HttpPort.url="your url here";
                        this.HttpPort.addEventListener(ResultEvent.RESULT,HttpPort_result)    
                        this.HttpPort.send();
                    }
                    else
                    {    
                    }
                }
            private function HttpPort_result(event:ResultEvent):void
            {
                this.DropPorts.open();
            }    
            ]]-->
        </mx:Script>

        <mx:HTTPService id="HttpPort" method="GET" />
        <mx:ComboBox id="DropPorts" keyDown="DropPorts_KeyDown(event);"
             labelField="Name"
             dataProvider="{HttpPort.lastResult.CityOcean.Port}" width="170" editable="true" textAlign="left"></mx:ComboBox>
        <mx:Text id="txtPortID" visible="false" height="0" width="0" text="{DropPorts.selectedItem.ID}" />        

</mx:FormItem>
您可能感兴趣的文章:
阅读全文