flex按值引用还是按对象引用

[cpp:nogutter] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"   
  3.                xmlns:s="library://ns.adobe.com/flex/spark"   
  4.                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)">  
  5.     <s:layout>  
  6.         <s:BasicLayout/>  
  7.     </s:layout>  
  8.     <fx:Script>  
  9.         <!--[CDATA[  
  10.             import com.firemax.controls.FireMaxAlert;  
  11.               
  12.             import mx.collections.ArrayCollection;  
  13.             import mx.events.FlexEvent;  
  14.               
  15.             [Bindable]  
  16.             public var listDemo:ArrayCollection;  
  17.               
  18.             var stringName:String = new String("李四");  
  19.               
  20.             protected function application1_creationCompleteHandler(event:FlexEvent):void  
  21.             {  
  22.                 // TODO Auto-generated method stub  
  23.                 listDemo=new ArrayCollection();  
  24.                   
  25.                 listDemo.addItem(new String("张三"));  
  26.                 listDemo.addItem(stringName);  
  27.                 listDemo.addItem(new String("王五"));  
  28.                   
  29.                   
  30.             }  
  31.   
  32.             protected function button1_clickHandler(event:MouseEvent):void  
  33.             {  
  34.                 // TODO Auto-generated method stub  
  35.                 stringName="麻子";  
  36.                 FireMaxAlert.show(listDemo.getItemAt(1).toString());  
  37.                 //FireMaxAlert.show(stringName);  
  38.             }  
  39.         ]]-->  
  40.     </fx:Script>  
  41.     <fx:Declarations>  
  42.         <!-- 将非可视元素(例如服务、值对象)放在此处 -->  
  43.     </fx:Declarations>  
  44.     <mx:DataGrid x="46" y="33" width="403" height="212" dataProvider="{listDemo}">  
  45.         <mx:columns>  
  46.             <mx:DataGridColumn headerText="列 1" dataField="col1"/>  
  47.         </mx:columns>  
  48.     </mx:DataGrid>  
  49.     <s:Button x="46" y="275" label="按钮" click="button1_clickHandler(event)"/>  
  50. </s:Application>  
posted @ 2012-02-18 14:02  张良  阅读(308)  评论(0编辑  收藏  举报