flex企业应用开发笔记-ArrayCollection绑定很讲究

<?xml version="1.0"?>
<!-- binding/ArrayBinding.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            [Bindable]
            public var myAC:ArrayCollection = new ArrayCollection([
                "One", "Two", "Three", "Four"]);
            [Bindable]
            public var myAC2:ArrayCollection = new ArrayCollection([
                "Uno", "Dos", "Tres", "Quatro"]);     
        ]]>   
    </mx:Script>
    <!--应用启动时或当 myAC被改变时,数据绑定会被更新-->
    <mx:Text id="text1" text="{myAC[0]}"/>
<!--应用启动时或当myAC被改变时或当myAC[0]被改变时,数据绑定会被更新   -->
    <mx:Text id="text2" text="{myAC.getItemAt(0)}"/>
    <mx:Button id="button1"
        label="Change Element"
        click="myAC[0]='new One'"/>
    <mx:Button id="button2"
        label="Change ArrayCollection"
        click="myAC=myAC2"/>
</mx:Application>

  

--这个网站www.sbybuy.com,应该能让你找到你要的答案

你可能感兴趣的:(Flex)