I spent too much time playing around with
this and can’t figure out what’s going wrong. If you debug further
you’ll see that the original contents of the project.pages array are
getting corrupted (the elements are getting deleted or something). I tried
removing certain bindings and didn’t really see much in the way of
improvement. You can see everything go haywire without even selectinga page,
just select First, then Second, then First again and you’ll see the TestViews
disappear (if you put a backgroundcolor on the views you’ll see it’s
really the label being set to empty string, not the thing disappearing). The
selection then has even more problems for reasons that I couldn’t
decipher.
See if you can eliminate data binding from
the equation entirely. Just have everything set using event handlers and
getter/setters, eliminate the curly braces. There may be something about all
the bindings and relationships that is getting it confused at runtime, but I
couldn’t figure it out at all.
The binding mechanism itself is a little
much for me to try to explain right now J But we use a different mechanism in Flex than was written for
Flash. You can see a little more of how it all gets set up if you look at the
generated-as files (see keep-generated-as in flex-config) but I warn you that
you may be seeing a little too much sausage being made J
Matt
From: Alex Cruikshank
[mailto:[EMAIL PROTECTED]
Sent: Monday, February 14, 2005
5:13 PM
To: [email protected]
Subject: [flexcoders] Losingdata
bindings after seemingly unrelated event.
Hi All,
We're developing an application that permits
selection of page objects
for editing from multiple views. We're
trying to data-bind each of
the views to a shared selection object to reduce
the connections
between components. This is working fine so
long as you don't
interact with other parts of the
application. We also have a section
list that filters the list of pages visible to the
user. It appears
that changing the section causes the views to lose
their bindings to
the selection object. This is confusing
because, section selection
only operates on another 'pages' array. I
don't understand why it
would affect the data bindings at all, especially
since the bindings
are to an unrelated object.
I've attached a stripped down version of the
application that exhibits
the same behavior. To see what I'm talking
about:
1. Click on the page labels on the right
side of the app. The word
'selected' should appear next to the page you
clicked last.
2. Click on 'First' or 'Second' on thecombo
box to the left.
3. Click on the page labels again to the
right. They no longer change.
The text for a page label is "{ page.label }{
selected(selection.list)
? ' (selected)' : '' }". Changes to
selection.list automatically
update this data binding _expression_ (at least
until you change the
selection).
I would greatly appreciate any insight that anyone
can provide. Also,
I would love to find an in-depth reference
describing how data binding
works in Flex/Flash.
Thanks,
Alex Cruikshank
Engineer
Carbon Five