It works if you switch the second text field so it looks like this:
<mx:Text
id="tab2"
text="({nbItems}) {labels.label.(@loc == locale)}" />
So it seems as though somehow the compiler gets confused by the deeper XML
parsing, and bypasses the subsequent binding call. Maybe somebody else has a
better explanation, but it looks like a bug to me.
Sid Maskit
Partner
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/
----- Original Message ----
From: Heiko Niemann <[EMAIL PROTECTED]>
To: [email protected]
Sent: Saturday, August 9, 2008 9:41:16 AM
Subject: [flexcoders] Data Binding works/does not work
Hi,
with the code below I experience some strange behaviour of the data
binding - at least it does not work the way I want. :)
There are two text fields each saying 'Cart' plus the number of items.
Then there are two buttons: one will increase the number of items and
the other will switch the language (so the second text field will
either say 'Cart' or 'Wagen').
Now - when I press 'add item' the number of items will just change in
the first text field. In the second text field the number of items
remains 0 - until I press the second button to switch languages. So
why is that? Is it because of the filter I use in the second text
field? Or is it simply a bug?
Thanks for your help,
Heiko
----
<?xml version="1.0" encoding="utf- 8"?>
<mx:Application
xmlns:mx="http://www.adobe. com/2006/ mxml"
layout="absolute" >
<mx:XML id="labels" xmlns="">
<labels>
<plain>Cart< /plain>
<label loc="en">Cart< /label>
<label loc="de">Wagen< /label>
</labels>
</mx:XML>
<mx:Number id="nbItems" >0</mx:Number>
<mx:String id="locale"> en</mx:String>
<mx:VBox>
<mx:Text
id="tab1"
text="{labels. plain} ({nbItems})" />
<mx:Text
id="tab2"
text="{labels. label.(@loc == locale)} ({nbItems})" />
<mx:Button
label="add item to cart"
click="{nbItems+ +}"/>
<mx:Button
label="switch language"
click="{locale = (locale == 'de') ? 'en' : 'de'}"/>
</mx:VBox>
</mx:Application>
-----