Hello,

I'd like to have several labels in alternating colors, 
and set their text's from XML-data coming from a server.

Unfortunately this won't compile:

  <mx:Label id="_leftTxt[0]" color="0x000000"/>
  <mx:Label id="_leftTxt[1]" color="0x000000"/>
  <mx:Label id="_leftTxt[2]" color="0x000000"/>
  <mx:Label id="_leftTxt[3]" color="0x000000"/>

And if I use Repeater, I can't set the components id's
(won't compile either; but it compiles if I change id -> text):

  <mx:Repeater id="rp" dataProvider="{[0, 1, 2, 3]}">
    <mx:Label id="{'_leftTxt'+String(rp.currentItem)}" 
      color="{rp.currentIndex % 2 == 0 ? 0x000000 : 0xFF0000}"/>
  </mx:Repeater>    

In Flash I could just have an array of TextFields:

  private var _leftTxt:Array = new Array(4);

  for (var i:uint = 0; i < _leftTxt.length; i++) {
    _leftTxt[i] = new TextField();
    ......
    addChild(_leftTxt[i]);
  }

and then just work with _leftTxt[i]... 
But how do you do it in Flex?

Regards
Alex



Reply via email to