One more thing on this, since it only sets the binding to nbItems if that is
done before the XML parsing, you could hack around the apparent bug in the
following ugly manner:
<mx:Text
id="tab2"
text="{(nbItems > 0 ? '' : '') + labels.label.(@loc == locale)} ({nbItems})" />
This sets the binding without affecting the string that is ultimately returned
to the text attribute.
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>
-----