- Do you have a class with read only properties?
- Need to bind to those properties?
- Getting: warning: unable to bind to property 'propertyName' on class 'com.example.package::ClassName'?
Add the Bindable metatag to your function and specify an event to be associated with it's update.
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
通过事件控制属性只读
package com.example.package {
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.collections.ArrayCollection;
public class ClassNameextends EventDispatcher {
private var _myExposedVar:ArrayCollection;
public function ClassName() { }
public function set resultsObject(value:Object):void {
/* Do Stuff with resultsObject and update _myExposedVar */
this.dispatchEvent(new Event("ResultsUpdated") );
}
[Bindable(event="ResultsUpdated")]
public function get myExposedVar ():ArrayCollection {
return this._myExposedVar;
}
}
}
通过赋值时发送事件,和捕捉事件,来控制属性只读。赋值即变成取值。