I think there's a misunderstanding of the [Bindable] Metatag here.
The Metatag only states that the compiler should create a property to which
we can bind another one, which means it should dispatch a property change
event every time it's value changes, but it doesn't bind it to anything.
[Bindable] private var xyz:String = MyModel.getInstance().someVar;
This means: create a bindable property xyz and initialize it with the value
of MyModel.getInstance().someVar. No binding here!
<mx:Label text="{xyz}"/>
This means create a Label and bind its "text" property to "xyz" which means:
everytime "xyz" changes, update "text" with its new value.
<mx:Label text="{MyModel.getInstance().someVar}"/>
This means create a Label and bind its "text" property
to" MyModel.getInstance().someVar" which means: everytime
"MyModel.getInstance().someVar" changes, update "text" with its new value.
BUT with all these commands, you didn't create any binding between "xyz" and
"MyModel.getInstance().someVar". They know nothing about each other besides
the fact that "xyz" has been initialized with the VALUE of
"MyModel.getInstance().someVar" during application initialization!
Hope this helps!
On Mon, Sep 22, 2008 at 5:26 AM, Manu Dhanda <[EMAIL PROTECTED]>wrote:
>
> Josh,
>
> Is it a right way to do the following:
>
>
> [Bindable] private var xyz:String = MyModel.getInstance().someVar;
>
> Now, if I use xyz in my code then it is not updated. Where as if i use
> 'MyModel.getInstance().someVar' then I am getting perfect result.
>
> For Ex:
>
> <mx:Label text="{xyz}"/> // view not updated with changes in model.
> <mx:Label text="{MyModel.getInstance().someVar}"/> //view updated everytime
> with changes in model.
>
> So, I didn't get the difference between two above logically.
>
> Please explain the case as above. Thanks.
>
>
> Josh McDonald-4 wrote:
> >
> > I get what you're saying, but you're coming at it from the wrong angle is
> > all.
> >
> > When you have this:
> >
> > [Bindable]
> > public var myvar = someFunction();
> >
> > You're making it so that *other code* will be called when myvar changes.
> > You're also giving it the initial value of someFunction(). It won't
> > "escape"
> > back into the code for someFunction() and alter it so it becomes
> bindable.
> > We need to have a difference betwen "X = Y" and "create a binding from X
> > to
> > Y", otherwise the entire virtual machine would slow to a crawl.
> >
> > If you want to create a binding from actionscript from
> > "sourceObject.someValue" to "myValue" you do this:
> >
> > BindingUtils.bindProperty(this, "myValue", sourceObject, "someValue");
> >
> > Then whenever sourceObject tells the word that "someValue" has been
> > updated
> > (with events), Flex will set the "myValue" field on your object.
> >
> > -Josh
> >
> > On Mon, Sep 22, 2008 at 1:07 PM, Manu Dhanda
> > <[EMAIL PROTECTED] <manuraj.dhanda%40gmail.com>>wrote:
> >
> >>
> >> Hi Paul,
> >>
> >> if [Bindable] works just for initialization, then I think it is loosing
> >> it's
> >> existence altogether.
> >>
> >> At least I think it this way.. that [Bindable] changes with every change
> >> that it is bind to. And not just it's initialization.
> >>
> >> Waiting for expert comments..
> >>
> >> Thanks,
> >> Manu.
> >>
> >>
> >> Paul Andrews-4 wrote:
> >> >
> >> > ----- Original Message -----
> >> > From: "Manu Dhanda" <[EMAIL PROTECTED]<manuraj.dhanda%40gmail.com>
> >
> >> > To: <[email protected] <flexcoders%40yahoogroups.com>>
> >> > Sent: Monday, September 22, 2008 3:08 AM
> >> > Subject: [flexcoders] [Bindable] is not getting updated..
> >> >
> >> >
> >> >>
> >> >> Hii Guyz,
> >> >>
> >> >> Although it's very strange (even for me), but this [Bindable] tag is
> >> not
> >> >> working for me.
> >> >>
> >> >> I am following the cairngorm structure and storing a variable in
> >> Model.
> >> >>
> >> >> Now, in one of my code file, if I 'll create a local bindable
> >> variable,
> >> >> that
> >> >> binds to model.. then it is not being updated with the changes in
> >> model.
> >> >>
> >> >> [Bindable] private var xyz:String = MyModel.getInstance().someVar;
> >> >>
> >> >> Now, if I use xyz in my code then it is not updated. Where as if i
> use
> >> >> 'MyModel.getInstance().someVar' then I am getting perfect result.
> >> >>
> >> >> Any thoughts here...
> >> >
> >> > Yes, some thoughts.
> >> >
> >> > [Bindable] private var xyz:String = MyModel.getInstance().someVar
> >> >
> >> > Means that xyz is bindable and is initialised with the value of
> >> > MyModel.getInstance().someVar .
> >> >
> >> > It does not mean that xyz changes with the value of
> >> > MyModel.getInstance().someVar .
> >> >
> >> > If you wish to have a binding in an mxml file to
> >> > MyModel.getInstance().someVar then use "{MyModel.getInstance().someVar
> >> > }",
> >> > alternatively in actionscript you'll have to specifically set up a
> >> binding
> >> > for it.
> >> >
> >> > Paul
> >> >
> >> >
> >> >
> >> >
> >> >>
> >> >> Regards,
> >> >> Manu.
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/-Bindable--is-not-getting-updated..-tp19600797p19600797.html
> >> >> Sent from the FlexCoders mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >> ------------------------------------
> >> >>
> >> >> --
> >> >> Flexcoders Mailing List
> >> >> FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >> >> Alternative FAQ location:
> >> >>
> >>
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> >> >> Search Archives:
> >> >> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo!
> Groups
> >> >> Links
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/-Bindable--is-not-getting-updated..-tp19600797p19601220.html
> >> Sent from the FlexCoders mailing list archive at Nabble.com.
> >>
> >>
> >> ------------------------------------
> >>
> >> --
> >> Flexcoders Mailing List
> >> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >> Alternative FAQ location:
> >>
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> >> Search Archives:
> >> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> >> Links
> >>
> >>
> >>
> >>
> >
> >
> > --
> > "Therefore, send not to know For whom the bell tolls. It tolls for thee."
> >
> > http://flex.joshmcdonald.info/
> >
> > :: Josh 'G-Funk' McDonald
> > :: 0437 221 380 :: [EMAIL PROTECTED] <josh%40gfunk007.com>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-Bindable--is-not-getting-updated..-tp19600797p19601339.html
> Sent from the FlexCoders mailing list archive at Nabble.com.
>
>
>
--
Haykel Ben Jemia
Allmas
Web & RIA Development
http://www.allmas-tn.com