当前位置: 首页 > 工具软件 > Object-proxy > 使用案例 >

关于ObjectProxy

蒋畅
2023-12-01

该类提供跟踪对此代理管理的项目进行的更改的功能。任何数量的对象都可使用 addEventListener() 方法“侦听”对此对象的更改。

此类为代理类。可以监听代理的Object对象是否进行更改:

?
<s:Application xmlns:fx= "http://ns.adobe.com/mxml/2009"
                xmlns:s= "library://ns.adobe.com/flex/spark" xmlns:mx= "library://ns.adobe.com/flex/mx"
                creationComplete= "initApp();" >
     <s:layout>
         <s:BasicLayout/>
     </s:layout>
  
     <s:Button x= "139" y= "444" label = "按钮" click= "button1_clickHandler(event)" />
     <fx:Script>
         <![CDATA[
             import mx.collections.ArrayCollection;
             import mx.controls.Alert;
             import mx.events.PropertyChangeEvent;
             import mx.utils.ObjectProxy;
             private var obj: Object ;
             private var o:ObjectProxy;
             private function initApp(): void
             {
                 obj= new Object ();           
                 o= new ObjectProxy(obj);
                 o.name= "@" ;
                 o.age= 18 ;
                 o.aa= "sa" ;
                 o.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,ChangeHandler);
             }
  
             protected function button1_clickHandler(event:MouseEvent): void
             {
                 o.name= "ok" ;
             }
             private function ChangeHandler(e:PropertyChangeEvent): void
             {
                 trace ( "发生变化" );
             }
  
         ]]>
     </fx:Script>
</s:Application>

也可以用于ArrayCollection里面的设置:

?
private var dataArr:ArrayCollection= new ArrayCollection
             ([
                 new ObjectProxy( Object ({location: "CF" ,id: "data/gril.png" , name: "刘德华" , skill: "data/idea.png" ,fight: 10000 , grade: "100" ,shot: "100" , onbreak: "100" ,speed: "10" ,strongth: "100" , block: "100" , save: "0.5" })),
                 new ObjectProxy( Object ({location: "SS" ,id: "data/boy.png" , name: "成龙" , skill: "data/idea.png" ,fight: 10000 , grade: "100" ,shot: "100" , onbreak: "100" ,speed: "20" ,strongth: "100" , block: "100" , save: "0.5" })),
                 new ObjectProxy( Object ({location: "RMF" ,id: "data/gril.png" , name: "李连杰" , skill: "data/idea.png" ,fight: 10000 , grade: "100" ,shot: "100" , onbreak: "100" ,speed: "30" ,strongth: "100" , block: "100" , save: "0.5" })),
                 new ObjectProxy( Object ({location: "RCM" ,id: "data/gril.png" , name: "张学友" , skill: "data/idea.png" ,fight: 10000 , grade: "100" ,shot: "100" , onbreak: "100" ,speed: "40" ,strongth: "100" , block: "100" , save: "0.5" })),
                 new ObjectProxy( Object ({location: "LCM" ,id: "data/boy.png" , name: "张国荣" , skill: "data/idea.png" ,fight: 10000 , grade: "100" ,shot: "100" , onbreak: "100" ,speed: "50" ,strongth: "100" , block: "100" , save: "0.5" })),
                 new ObjectProxy( Object ({location: "LMF" ,id: "data/gril.png" , name: "李宗盛" , skill: "data/idea.png" ,fight: 10000 , grade: "100" ,shot: "100" , onbreak: "100" ,speed: "60" ,strongth: "100" , block: "100" , save: "0.5" }))
             ]);

转载于:https://www.cnblogs.com/jiushini/archive/2012/04/30/2477283.html

 类似资料: