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>
    实例效果,在独立的窗口观看
  • 相关阅读:
    Struts2:<s:action>的使用
    Struts2:Struts2在jsp中使用标签时值的获取
    jsp:useBean的使用
    关于Filter的一点误解
    Strust2: 工作流程
    java程序连接MySQL数据库
    python 开发工具简介
    NCEP CFSR数据下载
    美国NOAA/AVHRR遥感数据
    气象网站
  • 原文地址:https://www.cnblogs.com/iihe602/p/1565024.html
Copyright © 2011-2022 走看看