0 Replies Latest reply on Apr 19, 2007 12:55 PM by thedex1

    using XML

      Hi, I am trying to use external XML file to display images and text. I use XML object to hold my XML data. But I don't know how to bind it with mx tags:
      Here is the XML file:
      <slide id="1">
      <headingText>Exercise for Beginners</headingText>
      <descText>Learn how to get started on your exercise program from your Health.com</descText>
      <slide id="2">
      <headingText>Think again</headingText>
      <descText>about your Health and Fitness</descText>

      Here is the Application:
      <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="680" height="300" creationComplete="getXMLData()" currentState="slide2">
      private function xmlDataHandler(event:Event):void
      var loader:URLLoader = event.target as URLLoader;
      myXML = new XML(loader.data);
      var arr:ArrayCollection = new ArrayCollection(loader.data);
      imageData = arr.event.Slides.slide.image;

      private function getXMLData():void
      var loader:URLLoader = new URLLoader();
      var request:URLRequest = new URLRequest("headerAnimData.xml");
      loader.addEventListener(Event.COMPLETE, xmlDataHandler);

      <mx:State name="slide2" id="a">
      <mx:SetProperty target="{headerImage}" id="aImage" name="source" value="{myXML.slide[1].image}" />
      <mx:SetProperty target="{headingText}" name="text" value="Think again" />
      <mx:SetProperty target="{descText}" name="text" value="about Your Health and Fitness" />
      <mx:State name="slide3" id="b">
      <mx:SetProperty target="{headerImage}" name="source" value="images/oranges.jpg" />
      <mx:SetProperty target="{headingText}" name="text" value="Eat Healthy" />
      <mx:SetProperty target="{descText}" name="text" value="Good nutrition and a balanced diet will help you and your child grow up healthy." />
      <mx:State name="slide4" id="c">
      <mx:SetProperty target="{headerImage}" name="source" value="images/womanWithGlasses.jpg" />
      <mx:SetProperty target="{headingText}" name="text" value="Be Happy" />
      <mx:SetProperty target="{descText}" name="text" value="Be happy and try to make other people happy as well" />

      This is not the complete code. I just want to set value of properties using XML data.
      headerImage is an <mx:Image ...>
      headingText is an <mx:Text..>
      descText is an <mx:Text...>

      Any help or suggestion will be greatly appretited.