zoukankan      html  css  js  c++  java
  • 在IViewCollection,使用IViewCursor进行查找对象

    这个例子将展示如何在IViewCursor上,使用IViewCursor查找特定的item
    下载 MXML
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundColor="white"
        horizontalAlign
    ="left"
        fontSize
    ="12" initialize="init()">
        
        
    <mx:Array id="coutries">
            
    <mx:Object label="Dlic" data="D"/>
            
    <mx:Object label="China" data="C"/>
            
    <mx:Object label="America" data="A"/>
            
    <mx:Object label="British" data="B"/>
        
    </mx:Array>
        
        
    <mx:ApplicationControlBar dock="true">
            
    <mx:Label text="查询:"/>
            
    <mx:Canvas> 
                
    <mx:TextInput id="searchText"/>
                
    <mx:Image id="img" source="" right="3" verticalCenter="0"/>            
            
    </mx:Canvas>
            
    <mx:Button label="go" icon="@Embed('assets/Input.PNG')" click="findHandler(event)"/>
        
    </mx:ApplicationControlBar>
        
        
    <mx:List id="cb" dataProvider="{collView}" width="150"/>

        
    <mx:Script>
            
    <![CDATA[
                import mx.collections.IViewCursor;
                import mx.collections.ArrayCollection;
                import mx.collections.ICollectionView;
                import mx.collections.Sort;
                import mx.collections.SortField;

                [Embed("assets/SuccessComplete.PNG")]
                private var okIcon:Class;
                
                [Embed("assets/Serious.PNG")]
                private var errorIcon:Class;
                
                [Bindable]
                private var collView: ICollectionView = null;
                
                private var sort:Sort = new Sort();

                private function init():void
                {                
                    //排序
                    collView = new ArrayCollection(coutries);
                    sort.fields = [new SortField("label", true)];
                    collView.sort = sort;
                    //务必进行刷新,否则,排序不会自动生效
                    collView.refresh();
                }
                
                private function findHandler(event:MouseEvent): void
                {
                    var vc: IViewCursor = collView.createCursor();
                    if (vc.findFirst({label:searchText.text}))
                    {
                        cb.selectedItem = vc.current;
                        img.source = okIcon;
                    }
                    else
                    {
                        cb.selectedItem = null;
                        img.source = errorIcon;
                    }
                }
            
    ]]>
        
    </mx:Script>
    </mx:Application>
    实例效果,在独立的窗口观看
  • 相关阅读:
    【磁盘/文件系统】第五篇:CentOS7.x__btrfs文件系统详解
    【python】-- IO多路复用(select、poll、epoll)介绍及实现
    【python】-- 事件驱动介绍、阻塞IO, 非阻塞IO, 同步IO,异步IO介绍
    【python】-- 协程介绍及基本示例、协程遇到IO操作自动切换、协程(gevent)并发爬网页
    【python】-- 多进程的基本语法 、进程间数据交互与共享、进程锁和进程池的使用
    【python】-- 队列(Queue)、生产者消费者模型
    【python】-- 信号量(Semaphore)、event(红绿灯例子)
    【python】-- GIL锁、线程锁(互斥锁)、递归锁(RLock)
    【python】-- 继承式多线程、守护线程
    【python】-- 进程与线程
  • 原文地址:https://www.cnblogs.com/iihe602/p/1565024.html
Copyright © 2011-2022 走看看