0 Replies Latest reply on Jul 24, 2008 4:00 AM by javar1984

    using MenuBar

    javar1984
      Hi, i am trying to load the data of the MenuBar element dynamically using HttpService, for now its enough for me to load the xml from a .xml file in the same directory of the .swf file.

      the xml file contents are as follows:
      <?xml version="1.0" encoding="utf-8"?>
      <menu>
      <menuitem label="MenuItem A">
      <menuitem label="SubMenuItem A-1" enabled="false"/>
      <menuitem label="SubMenuItem A-2"/>
      </menuitem>
      <menuitem label="MenuItem B"/>
      <menuitem label="MenuItem C"/>
      <menuitem label="MenuItem D">
      <menuitem label="SubMenuItem D-1"
      type="radio" groupName="one"/>
      <menuitem label="SubMenuItem D-2"
      type="radio" groupName="one"
      selected="true"/>
      <menuitem label="SubMenuItem D-3"
      type="radio" groupName="one"/>
      </menuitem>
      </menu>


      the application i wrote to load the xml file contains the following:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application width="450" height="400" xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init();">
      <mx:Script>
      <![CDATA[
      import mx.controls.*;
      import mx.rpc.events.*;
      import mx.collections.*;
      [Bindable]
      private var menuData:XML;
      private function faultHandler(evt:Event):void{Alert.show("error loading data");}
      private function init():void{menuDataProvider.send();}
      private function loadData(evt:ResultEvent):void{menuData = evt.result as XML;}
      ]]>
      </mx:Script>
      <mx:HTTPService id="menuDataProvider" url="menu.xml" fault="faultHandler(event);" result="loadData(event)"/>
      <mx:MenuBar left="10" top="10" right="10" dataProvider="{menuData}" showRoot="false"/>
      </mx:Application>


      i have tried to replace the XML variable with an XMLList variable but its not working. i also changed the resultFormat of the HttpService tag to (e4x) and used the evt.result..menuitem, at this time it loades the xml text in the menubar without parsing it. ... any help please ??