Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3245372
  • 博文数量: 530
  • 博客积分: 13360
  • 博客等级: 上将
  • 技术积分: 5473
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-13 13:32
文章分类

全部博文(530)

文章存档

2017年(1)

2015年(2)

2013年(24)

2012年(20)

2011年(97)

2010年(240)

2009年(117)

2008年(12)

2007年(8)

2006年(9)

分类: 系统运维

2011-10-24 09:37:15

1.简介
       继承关系:PropertyChangeEvent Inheritance Inheritance
       如果对象的属性值发生变化,可以派发PropertyChangeEvent事件来表示。
       Flex 数据绑定机制也使用此事件。
       例子请参考《PropertyChangeEvent事件

2.常见属性和方法
2.1 属性PROPERTY_CHANGE
PROPERTY_CHANGE : String = "propertyChange"
[静态] PropertyChangeEvent.PROPERTY_CHANGE 常量可为 PropertyChange 事件定义事件对象的 type 属性的值。

2.2 属性kind
指定更改的类型。String类型
可能的值为 PropertyChangeEventKind.UPDATE、PropertyChangeEventKind.DELETE 和 null

2.3 属性newValue

更改后的属性的值。Object类型

2.4 属性oldValue
更改前的属性的值。Object类型

2.5 属性property
需要更改的属性Object类型

2.6 属性source
发生更改属性的对象。Object类型

2.7 属性currentTarget
用于定义处理该事件的事件侦听器的 Object。Object类型
例如,如果您使用myButton.addEventListener() 注册某个事件侦听器,则 myButton 为 currentTarget 的值。

2.8 属性target
事件目标。Object类型
派发事件的 Object;它不一定是侦听该事件的 Object。使用 currentTarget 属性始终可以访问侦听事件的 Object。


3.源代码
  1. package mx.events
  2. {

  3. import flash.events.Event;
  4. import mx.events.PropertyChangeEventKind;

  5. public class PropertyChangeEvent extends Event
  6. {
  7.     include "../core/Version.as";

  8.     //类属性
  9.     public static const PROPERTY_CHANGE:String = "propertyChange";

      //类方法
  1.     public static function createUpdateEvent(
  2.                                     source:Object,
  3.                                     property:Object,
  4.                                     oldValue:Object,
  5.                                     newValue:Object):PropertyChangeEvent
  6.     {
  7.         var event:PropertyChangeEvent =
  8.             new PropertyChangeEvent(PROPERTY_CHANGE);
  9.         
  10.         event.kind = PropertyChangeEventKind.UPDATE;
  11.         event.oldValue = oldValue;
  12.         event.newValue = newValue;
  13.         event.source = source;
  14.         event.property = property;
  15.         
  16.         return event;
  17.     }

  18.     // 构造函数
  19.     public function PropertyChangeEvent(type:String, bubbles:Boolean = false,
  20.                                         cancelable:Boolean = false,
  21.                                         kind:String = null,
  22.                                         property:Object = null,
  23.                                         oldValue:Object = null,
  24.                                         newValue:Object = null,
  25.                                         source:Object = null)
  26.     {
  27.         super(type, bubbles, cancelable);

  28.         this.kind = kind;
  29.         this.property = property;
  30.         this.oldValue = oldValue;
  31.         this.newValue = newValue;
  32.         this.source = source;
  33.     }

  34.     // 属性kind
  35.     public var kind:String;

  36.  
  37.     // 属性newValue
  38.     public var newValue:Object;


  39.     // 属性 oldValue
  40.     public var oldValue:Object;


  41.     // 属性property
  42.     public var property:Object;

  43.     // 属性source
  44.     public var source:Object;

  45.     //方法clone,继承自Event
  46.     /**
  47.      * @private
  48.      */
  49.     override public function clone():Event
  50.     {
  51.         return new PropertyChangeEvent(type, bubbles, cancelable, kind,
  52.                                        property, oldValue, newValue, source);
  53.     }
  54. }

  55. }

参考文献
1.类参考.
2.源代码.
阅读(1568) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~