I'd like to create a data model that will hold a lot of the
labels/form data etc for the UI elements in my application. I'm
doing this so I have better control of the state of the
application. So I can clear all form fields when a user logs out,
for example, by simply clearing the data model rather than
referencing the form elements themselves.
I'd like all these variables to be under a parent scope, just
for organisational purposes. So for example my data model may be
set up like so
when I load up that page, the text says "testing1" as is
expected. However if I then change value of
myParentScope.myChildScope1.text1, I'd like the text to update
automatically. I test this by simply creating a button to change
the value of that variable.
I have verified that the value of that variable is changing,
but the text doesn't update unless I tell it to with something like
myText.text = myParentScope.myChildScope1.text1;
Is there a way to get this happening automatically? I have
tried using mx:Binding but with no success.
Did a little search and found something about objectProxy -
is that what I need to be looking into? with a quick glance I
didn't really understand the objectProxy stuff, and don't want to
waste my time with it if it's not going to solve the problem.
You cannot bind to the properties of a plain Object--no
updates will happen (you should get a compiler warning about it).
My suggestion is to create your own bindable classes to describe
the parent and child scopes. eg:
public var text1: String
public var text2: String
public var childScope1: ChildScope1;
Or, simpler yet, maybe you can declare a nested Model in the
MXML. That should work.