0 Replies Latest reply on Jan 28, 2012 11:00 PM by jefecame

    Using the XML Service with MenuBar

    jefecame

      Hello, I hope some one can help me. I'm learning how to use the new XML Service that comes with the new Flash Builder. I want to connect a MenuBar Control with an XML Service (from a local XML file) throgh the design view in Flash Builder.

       

      In previous version I used to create an XML object inside fx:Declaration like this:

       

      fx:Declarations>
              <fx:XML format="e4x" id="myMenuModel">
                  <root label="Menu">
                      <menuitem label="MenuItem A">
                          <menuitem label="SubMenuItem 1-A"/>
                          <menuitem label="SubMenuItem 2-A" />
                      </menuitem>
                      <menuitem label="MenuItem B"/>
                      <menuitem label="MenuItem C" type="check"/>
                      <menuitem type="separator"/>
                      <menuitem label="MenuItem D">
                          <menuitem label="SubMenuItem 1-D" type="radio" groupName="one"/>
                          <menuitem label="SubMenuItem 2-D" type="radio" groupName="one"/>
                          <menuitem label="SubMenuItem 3-D" type="radio" groupName="one"/>
                      </menuitem>
                  </root>
              </fx:XML>
      fx:Declarations>
      

       

      or with a external local XML file like this:

       

      fx:Declarations>
              <fx:XML format="e4x" id="myMenuModel" source="assets/data/myData.xml"/>
      fx:Declarations>
      

       

      and then I usually go to Design View I drag a MenuBar Control onto the layout and Inside the Properties Tab under the Common group I change the Data provider value to {myMenuModel} and making sure the code looks like this:

       

       

      <mx:MenuBar id="myMenu" labelField="@label">
              <mx:dataProvider>
                  {myMenuModel}
              </mx:dataProvider>
       </mx:MenuBar>
      

       

      But I haven´t been able to do it with an external Local XML file using the XML Service in  theData Services View in Flash Builder 4.6.

       

      First I created the XML and saved it in the src/assets/data folder like myData.xml, this is the xml code:

       

      <?xml version="1.0" encoding="utf-8"?>            
                   <root label="Menu">
                      <menuitem label="MenuItem A">
                          <menuitem label="SubMenuItem 1-A"/>
                          <menuitem label="SubMenuItem 2-A" />
                      </menuitem>
                      <menuitem label="MenuItem B"/>
                      <menuitem label="MenuItem C" type="check"/>
                      <menuitem type="separator"/>
                      <menuitem label="MenuItem D">
                          <menuitem label="SubMenuItem 1-D" type="radio" groupName="one"/>
                          <menuitem label="SubMenuItem 2-D" type="radio" groupName="one"/>
                          <menuitem label="SubMenuItem 3-D" type="radio" groupName="one"/>
                      </menuitem>
                  </root>
      

       

      Second, I run the connect to Data Service Wizard and choose XML (Connects to local XML file or url returning XML response) selecting the local file myData.xml.

       

      Third, I drag a MenuBar Control to the layout.

       

      And finally I have been dragging the service in different ways to the MenuBar control with no luck.

       

      I would appreciate any help.

      Thanks in advance.