Flex IViewCursor(游标定位数组)

<?xml version="1.0"?>
<!-- dpcontrols\GetAddRemoveItems.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        initialize="initData();">
    <mx:Script>
        <![CDATA[
            import mx.collections.*;
            public var myArray:Array = [{label:"MA", data:"Massachusetts"}, 
            {label:"MN", data:"Minnesota"}, {label:"MO", data:"Missouri"}];
            [Bindable]
            public var myAC:ArrayCollection; 
            public var myCursor:IViewCursor;

            /* Initialize the ArrayCollection when you
               initialize the application. */
            public function initData():void {
                myAC = new ArrayCollection(myArray); 
            }

            /* The function to change the collection,
               and therefore the Array. */
            public function testCollection():void {
                /* Get an IViewCursor object for accessing the collection data. */
                myCursor=myAC.createCursor();
                ta1.text="At start, the cursor is at: " + myCursor.current.label + ".";
                var removedItem:String=String(myCursor.remove());
                ta1.text+="\nAfter removing the current item, the cursor is at: " 
                    + myCursor.current.label + ".";
                myCursor.insert({label:"ME", data:"Augusta"});
                ta1.text+="\nAfter adding an item, the cursor is at: " 
                    + myCursor.current.label + ".";
            }
        ]]>
    </mx:Script>

    <mx:ComboBox id="myCB" rowCount="7" dataProvider="{myAC}"/>
    <mx:TextArea id="ta1" height="75" width="350"/> 
    <mx:Button label="Run Test" click="testCollection();"/>
</mx:Application>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值