0 Replies Latest reply on Oct 26, 2006 5:08 AM by Whitetimer

    XML won't load - Help

    Whitetimer Level 1
      Hi All

      I'm trying to load an xmal document with a structure of :
      <aboutus>
      <person>
      <name></name>
      <title></title>
      <description></description>
      <contact>
      <telephone></telephone>
      <mobile></mobile>
      <email></email>
      </contact>
      </person>
      </aboutus>

      And this is my code so far

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="860" height="560" label="About Us" show="resetState(event)" initialize="myAboutUs.send()">


      <mx:Script>
      <![CDATA[

      import mx.rpc.events.ResultEvent;

      [Bindable]
      private var aboutUsData:XMLList = new XMLList;

      private function aboutUsResultHandler(event:ResultEvent) : void {
      aboutUsData = event.result.aboutus.person;
      }

      private function resetState(event:Event) : void {
      currentState = '';
      }

      ]]>
      </mx:Script>


      <mx:HTTPService id="myAboutUs" url="xml/aboutus.xml" result="aboutUsResultHandler(event)" resultFormat="e4x" />


      <!-- BASE STATE -->
      <mx:VBox id="vbAbout1" x="5" y="5" width="850" height="50" horizontalAlign="center" verticalAlign="middle">

      <mx:LinkButton label="Who We Are" id="lbAbout" click="this.currentState = 'cvAboutUs'"/>

      </mx:VBox>

      <mx:VBox id="vbAbout2" x="5" y="55" width="850" height="500" horizontalAlign="center" verticalAlign="middle">

      <mx:Text id="txtAboutUs"
      width="750" height="400"
      textAlign="center"
      color="#000080"
      enabled="true">


      </mx:Text>

      </mx:VBox>

      <!-- CHILD STATES -->
      <mx:states>
      <mx:State name="cvAboutUs">
      <mx:RemoveChild target="{txtAboutUs}"/>
      <mx:RemoveChild target="{vbAbout2}"/>
      <mx:SetProperty target="{lbAbout}" name="label" value="Back"/>
      <mx:SetEventHandler target="{lbAbout}" name="click" handler="this.currentState = ''"/>

      <mx:AddChild position="lastChild">
      <mx:HBox x="5" y="55" width="850" height="500" id="aboutUsMain" horizontalGap="50">

      <mx:VBox width="400" height="500" id="aboutUsImage" horizontalAlign="center" verticalAlign="middle">
      <mx:ComboBox width="200" height="20" dataProvider="{aboutUsData}" labelField="name" />
      <mx:Spacer width="200" height="20"/>

      <mx:Image id="auPic" width="200" height="200" />
      <mx:Label id="auName" text="Name" width="200" height="20"/>
      <mx:Label id="auTitle" text="Job Title" width="200" height="20"/>
      <mx:Label id="auEmail" text="Email Address" width="200" height="20"/>

      </mx:VBox>

      <mx:VBox width="400" height="500" id="aboutUsDetail" horizontalAlign="center" verticalAlign="middle">

      <mx:Text text="Who We Are" width="300" height="400" id="aboutUsText"/>

      </mx:VBox>

      </mx:HBox>
      </mx:AddChild>

      </mx:State>
      </mx:states>

      </mx:Canvas>

      What i'm trying to do is to load the xml file and display the relevant information in the label boxs and text boxes.

      Alternatively i'd like to use a dynamic link button instead of the combobox.

      Any suggestions .... ?

      Many thanks

      Whitetimer