Flex - Issues with linkbar dataprovider

Posted by BS_C3 on Stack Overflow See other posts from Stack Overflow or by BS_C3
Published on 2010-03-16T15:45:23Z Indexed on 2010/03/17 13:01 UTC
Read the original article Hit count: 359

Filed under:
|
|

Hello Community!

I'm having some issues displaying a linkbar.

The data I need to display is in a XML file. However, I couldn't get the linkbar to display a xmllist (I did indeed read that you cannot set a xmlllist as a linkbar dataprovider... ). So, I'm transforming the xmllist in a array of objects.

Here is some code.

XML file:

<data>
 <languages>
  <language id="en">
   <label>ENGLISH</label>
   <source></source>
  </language>
  <language id="fr">
   <label>FRANCAIS</label>
   <source></source>
  </language>
  <language id="es">
   <label>ESPAÑOL</label>
   <source></source>
  </language>
  <language id="jp">
   <label>JAPANESE</label>
   <source></source>
  </language>
 </languages>
</data>

AS Code that transforms the xmllist in an array of objects:

private function init():void
{
 var list:XMLList = generalData.languages.language;
 var arr:ArrayCollection = new ArrayCollection;
 var obj:Object;
 for(var i:int = 0; i<list.length(); i++)
 {
  obj = new Object;
  obj.id = list[i].@id;
  obj.label = list[i].label;
  obj.source = list[i].source;
  arr.addItemAt(obj, arr.length);
 }    
 GlobalData.instance.languages = arr.toArray();
}

Linkbar code:

<mx:HBox horizontalAlign="right" width="100%">
 <mx:LinkBar id="language" dataProvider="{GlobalData.instance.languages}" separatorWidth="3" labelField="{label}"/>
</mx:HBox>

The separator is not displaying, and neither do the label. But the array is populated (I tested it).

Thanks for any help you can provide =)

Regards, BS_C3

© Stack Overflow or respective owner

Related posts about flex

Related posts about dataprovider