8 Replies Latest reply on Aug 11, 2009 7:58 AM by Gregory Lafrance

    Populate TabBar From ArrayCollection!!!

    Gargantus

      Hello there,

       

      I am just wondering if any one can help me with this problem.

      I have ArrayCollection which is being populated from splitting an xm list into seperate objects.

      These objects are then given label, name and id variables from the xml.

      I then use this ArrayCollection to piopulate a TabBar.

      This works fine but the labels are not showing, even if i set the labelfield to one of the objects variables ie name

      Any idea how to get my labels showing will be greatly appreciated as i've been banging my head on the desk for a few hours now.

       

       

      <mx:Canvas
      
       xmlns:mx="http://www.adobe.com/2006/mxml" width="400" >
      
      
      <mx:Style>
      
      .customTabStyleName {
      
      textAlign: left;}
      
      
      </mx:Style>
      
      
      <mx:Script>
      <![CDATA[
      
      import mx.validators.ValidationResult;
      
      import mx.collections.ArrayCollection;
      
      import mvc.*;
      
      import classes.*;
      
      import mx.events.*;[
      
      Bindable]
      
      public var ProjectArray:ArrayCollection;
      
      import mx.controls.tabBarClasses.Tab;
      
      
      public function init():void{
      ProjectArray = 
      new ArrayCollection();
      
      for each(var item:XML in Model.getInstance().xmlData.project){
      
      
      var obj:Object = new Object;obj.name = item.level[0].@name;
      
      
      trace(item.level[0].@name);obj.label = item.level[0].@name;
      obj.id = item.@id
      ProjectArray.addItem(obj);
      
      
      
      }
      
      
      
      
      if (ProjectArray.length > 0) {
      mx.core.Application.application.projectDetails.enabled = 
      
      true;
      }
      
      
      else{
      mx.core.Application.application.projectDetails.enabled = 
      false;}
      }
      
      
      
      
      private function selectData(event:ItemClickEvent):void{
      
      trace(event.item.id);
      
      if (event.item != null)
      
      this.dispatchEvent(new EventProject(event.item.id, EventProject.SELECT, true));}
      
      ]]>
      
      
      </mx:Script>
      
      
      
      <mx:TabBar id="tabBar"direction="
      
      horizontal"tabStyleName="
      
      customTabStyleName"dataProvider="
      
      {ProjectArray}" labelField="
      
      name"width="
      
      100%" itemClick="selectData(event)" />
      
      
      
      
      
      </mx:Canvas>