But if there is no setter function...
protected var _testVar:uint = 10;
[Bindable]
public function get testVar():uint
{
return _testVar;
}
...then my class can only modify testVar through the protected
_testVar property - which isn't bindable and therefore does not cause
data bindings to update!
(Flex Builder warns of this with "[Bindable] on read-only getter is
unnecessary and will be ignored")
Nick.
--- 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.
>