0 Replies Latest reply on May 2, 2010 11:52 PM by welcomecan

    how to create dynamic arraycollection menu item in flex?

    welcomecan Level 1

      hi to all,

      any body help me,

        i am doing dynamic arraycollection menu bar. my source code below  but it is not working

       

       

      ?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="initData()" minWidth="955" minHeight="600">
          <fx:Script>
              <![CDATA[
                         
                      import mx.collections.*;
                      [Bindable]
                      public var stateArray:ArrayCollection;
                     
                      private function initData():void {
                          stateArray=new ArrayCollection(
                              [{label:"AL"},
                                  {label:"AK"},
                                  {label:"AR"}]);
                      }

       

       

       

       

       

                  //
                  /* for (var i:uint; i < s.length; i++) {
                      trace(s[i]);
                  }  */
                  //ww.dataProvider=s[0];
                  //trace(expense);
                 
                 
                 
              ]]>
          </fx:Script>
          <mx:MenuBar id="ss" labelField="@label">
              <mx:dataProvider>
                  <mx:XMLListCollection>
             
                  <fx:XMLList xmlns="">
                     
                      <menu label="@stateArray[0]" >
                          <item label="@stateArray[1]" />
                          <item label="@stateArray[2]" />
                        
                      </menu>
                  </fx:XMLList>
                     
                      </mx:XMLListCollection>
              </mx:dataProvider>
          </mx:MenuBar>

       

         
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
      </s:Application>

       

       

      give solution please

       

      regards,

      welcanv