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>

-----

Reply via email to