Binding On A Class' Read Only Property

Jun 10, 2009
  • 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.

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;
        }

    }
}

Problem solved.

Comments

Bogguard

Bogguard wrote on 12/22/09 10:09 AM

you made my day

Write your comment



(it will not be displayed)



Subscribe to this comment thread