我自己测试了下几种不同bindable,编译后的源码。
几个测试:
1、一个非继承自EventDispatcher的类来加Bindable
转化为:package
{
[Bindable]
public class TestBind
{
public var prop:String;
}
}
package
{
import flash.events.*;
import mx.events.*;
public class TestBind extends Object implements IEventDispatcher
{
private var _bindingEventDispatcher:EventDispatcher;
private var _3449699prop:String;
public function TestBind()
{
_bindingEventDispatcher = new EventDispatcher(IEventDispatcher(this));
return;
}// end function
public function dispatchEvent(event:Event) : Boolean
{
return _bindingEventDispatcher.dispatchEvent(event);
}// end function
public function get prop() : String
{
return this._3449699prop;
}// end function
public function set prop(param1:String) : void
{
var _loc_2:* = this._3449699prop;
if (_loc_2 !== param1)
{
this._3449699prop = param1;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "prop", _loc_2, param1));
}
return;
}// end function
public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
{
_bindingEventDispatcher.removeEventListener(param1, param2, param3);
return;
}// end function
public function hasEventListener(param1:String) : Boolean
{
return _bindingEventDispatcher.hasEventListener(param1);
}// end function
public function willTrigger(param1:String) : Boolean
{
return _bindingEventDispatcher.willTrigger(param1);
}// end function
public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
{
_bindingEventDispatcher.addEventListener(param1, param2, param3, param4, param5);
return;
}// end function
}
}
2、一个继承自EventDispatcher的类来加Bindable
转化为package
{
import flash.events.EventDispatcher;
[Bindable]
public class TestBind extends EventDispatcher
{
public var prop:String;
}
}
package
{
import flash.events.*;
import mx.events.*;
public class TestBind extends EventDispatcher
{
private var _3449699prop:String;
public function TestBind()
{
return;
}// end function
public function get prop() : String
{
return this._3449699prop;
}// end function
public function set prop(param1:String) : void
{
var _loc_2:* = this._3449699prop;
if (_loc_2 !== param1)
{
this._3449699prop = param1;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "prop", _loc_2, param1));
}
return;
}// end function
}
}
3、自定义bind 事件和不自定义bind事件
转化为package
{
import flash.events.Event;
import flash.events.EventDispatcher;
[Bindable]
public class TestBind extends EventDispatcher
{
private var _prop:String;
[Bindable("propChanged")]
public function get prop():String
{
return _prop;
}
public function set prop(value:String):void
{
_prop = value;
dispatchEvent(new Event("propChanged"));
}
public var prop2:String;
}
}
package
{
import flash.events.*;
import mx.events.*;
public class TestBind extends EventDispatcher
{
private var _prop:String;
private var _106940719prop2:String;
public function TestBind()
{
return;
}// end function
public function get prop() : String
{
return _prop;
}// end function
public function set prop(param1:String) : void
{
_prop = param1;
dispatchEvent(new Event("propChanged"));
return;
}// end function
public function set prop2(param1:String) : void
{
var _loc_2:* = this._106940719prop2;
if (_loc_2 !== param1)
{
this._106940719prop2 = param1;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "prop2", _loc_2, param1));
}
return;
}// end function
public function get prop2() : String
{
return this._106940719prop2;
}// end function
}
}