Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex - Issues with linkbar dataprovider
    primarykey
    data
    text
    <p>I'm having some issues displaying a linkbar.</p> <p>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.</p> <p>Here is some code.</p> <p>XML file:</p> <pre><code>&lt;data&gt; &lt;languages&gt; &lt;language id="en"&gt; &lt;label&gt;ENGLISH&lt;/label&gt; &lt;source&gt;&lt;/source&gt; &lt;/language&gt; &lt;language id="fr"&gt; &lt;label&gt;FRANCAIS&lt;/label&gt; &lt;source&gt;&lt;/source&gt; &lt;/language&gt; &lt;language id="es"&gt; &lt;label&gt;ESPAÑOL&lt;/label&gt; &lt;source&gt;&lt;/source&gt; &lt;/language&gt; &lt;language id="jp"&gt; &lt;label&gt;JAPANESE&lt;/label&gt; &lt;source&gt;&lt;/source&gt; &lt;/language&gt; &lt;/languages&gt; &lt;/data&gt; </code></pre> <p>AS Code that transforms the xmllist in an array of objects:</p> <pre><code>private function init():void { var list:XMLList = generalData.languages.language; var arr:ArrayCollection = new ArrayCollection; var obj:Object; for(var i:int = 0; i&lt;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(); } </code></pre> <p>Linkbar code:</p> <pre><code>&lt;mx:HBox horizontalAlign="right" width="100%"&gt; &lt;mx:LinkBar id="language" dataProvider="{GlobalData.instance.languages}" separatorWidth="3" labelField="{label}"/&gt; &lt;/mx:HBox&gt; </code></pre> <p>The separator is not displaying, and neither do the label. But the array is populated (I tested it).</p> <p>Thanks for any help you can provide =)</p> <p>Regards, BS_C3</p> <hr> <p>@Decado</p> <p>Here's the code for the linkbar I used:</p> <pre><code>&lt;mx:LinkBar id="language" dataProvider="{GlobalData.instance.languages}" labelFunction="language_labelFunction" itemClick="language_itemClick(event)" styleName="GLBLinkBTN" separatorColor="#FFFFFF" separatorWidth="1" linkButtonStyleName="HPLanguages" /&gt; </code></pre> <p>And here's the function for the labelfunction:</p> <pre><code>private function language_labelFunction(item:Object):String { return item.label; } </code></pre> <p>Hope this helps. Regards</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload