You can also use a custom event, and use the same one for multiple (computed) properties. I wrote this up here:
http://flexygen.wordpress.com/2008/01/24/computed-properties-and-binding/ On Sat, Mar 1, 2008 at 10:01 AM, JustusLogan <[EMAIL PROTECTED]> wrote: > I read the links provided by Doug (thanks!) and came up with this. Keep > in mind that the "age" property doesn't have an instance field, so there's > no possibility of a corresponding setter. Therefore, the change event needed > to be broadcast from the set dob (i.e., changing one's DOB also change's > one's age). Note that there's a [Bindable] on the whole class, to allow > bindings to other properties. > > > public function set dob(dob:Date):void { > var oldAge:int = age; > this._dob = dob; > this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "age", > oldAge, age)); > } > > [Bindable(event="propertyChange")] > public function get age():int{ > // Yes, this is a poor algorythm. It's just to illustrate a point! > return (new Date().getTime() - dob.getTime()) / 1000 / 60 / 60 / 24 / > 365; > > } > > > --- In [email protected], "Doug McCune" <[EMAIL PROTECTED]> wrote: > > > > You can make read-only properties bindable. In your case your age > property > > is a read-only property since it only has a getter. The normal bindable > > stuff doesn't work on that because bindable properties require both a > getter > > and a setter to work. But if you define only a getter you can still use > the > > [Bindable] metadata tag, but you have to dispatch a custom event that > tells > > everything that the value has updated. > > > > Check out these links: > > http://www.rubenswieringa.com/blog/binding-read-only-accessors-in-flex > > > http://dynamicflash.com/2006/12/databinding-to-read-only-properties-in-flex-2/ > > > >

