FLEX 仿Google联想框效果

论坛 期权论坛 脚本     
niminba   2021-5-23 02:49   919   0
首先是事件源,也就是从何而起,如下的一个输入框:
复制代码 代码如下:

<mx:FormItem label="集团客户:" width="42%">
<!--change1-->
<mx:TextInput id="txtAssociation" width="235" maxChars="32" change="associate();"/>
</mx:FormItem>

然后就是处理效果,这些内容都是从数据库得到的数据,动态的查出的。
复制代码 代码如下:

import mx.collections.ArrayCollection;
            import mx.events.FlexMouseEvent;
            import mx.events.ListEvent;
            import mx.managers.PopUpManager;

            import resources.com.list.Association;

            // 经过渲染的联想结果List
            private var list:Association;
            // 临时字符串,用于判断当keyUp事件发生时,联想框的值是否发生改变,如未改变则不联想
            private var temp:String = '';
            private function changeAssociation():void{
                temp='';
                txtAssociation.text='';
                associationResult=null;
                if(list != null){
                    PopUpManager.removePopUp(list);
                    list = null;
                    // 清空临时字符串
                }
        }
            private function associate():void {
                var str:String = txtAssociation.text;
                if(str.length<2){
                    associationResult=null;
                }
                if (str != temp) {
                    if(str.length < 2){
                         if(list != null){
                             PopUpManager.removePopUp(list);
                             list = null;
                             // 清空临时字符串
                            temp = '';
                        }
                         return;
                    }
                    temp = str;

                    var params:Object = {};
                    params['areaIйфAйхФ=!5ФAйхФA^_й5=UM}=]9}=UQM%=!ASg3B FFǒ:"g3>{:ф7" % t5m QlйIЙ 齹х1Ёф1ЁфЁф ЙIх1`SV#zp:rrZ"jV#zp:rR+j*{vjFF"Gr'krObn{:~V#zp&k*~
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1060120
帖子:212021
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP