For read-only properties yu don't set them as Bindable "Because the data binding from a read-only property occurs only once at application start up, you omit the [Bindable] metadata tag for the read-only property."
Paul --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > Don't implement the setter function? > > Tracy > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of durnelln > Sent: Wednesday, March 07, 2007 12:33 PM > To: [email protected] > Subject: [flexcoders] Databinding of a read only property > > > > Hi all, > > How do I make a read-only property bindable for users of my class? > It sounds so simple but has me stumped at the moment. I'm sure there > must be a simple solution but for the life of me I can't figure it > out... > > E.g. say I have a property testProp which is maintained by my class > and must not be publicly set-able from outside. I do however want > outside users to be able to bind to testProp so that they receive > notifications when it changes. > > An example of a read-only bindable property would be > ArrayCollection.length. You can bind to this but cannot change it. > How do I do the same thing with testProp? > > I tried... > > protected var _testVar:uint = 10; > [Bindable] > public function get testVar():uint > { > return _testVar + 1; > } > protected function set testVar(value:uint):void > { > _testVar = value; > } > > ...hoping to hide the setter from the outside world but outside users > CAN still change testProp with myClassInstance.testProp=10!! > > Thanks for your help, > > Nick. >

