9 Replies Latest reply on Feb 27, 2009 3:13 AM by dersler

    loading a single image from external xml

    idea-boss
      Hi all, I am struck up with an issue in flex 3
      Below is the mxml code:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="vertical" creationComplete="siteData.send()">
      <mx:Script>
      <![CDATA[
      private var siteContent:XMLList;
      private function showPage(targetPage:String):void{
      //Search for title of target page
      siteContent = siteData.lastResult.page.(@location==targetPage).title;
      //Show result in label
      headerText.text=siteContent;

      //Search for body text of target page
      siteContent = siteData.lastResult.page.(@location==targetPage).text;
      //Show result in label
      bodyText.text=siteContent;
      }
      ]]>
      </mx:Script>

      <mx:HTTPService url="loadxml.xml" id="siteData" resultFormat="e4x"/>
      <mx:VBox>
      <mx:Image source="loadxml.xml"/>
      <mx:Label fontSize="24" id="headerText" text="Click a Button"/>
      <mx:Label id="bodyText" text="The choice is yours!"/>
      <mx:HBox>
      <mx:Button label="Home Page" />
      <mx:Button label="About Page" click="showPage('about')"/>
      <mx:Button label="Contact Page" click="showPage('contact')"/>
      </mx:HBox>
      </mx:VBox>
      </mx:Application>
      quote:

      Text


      and below is the xml file for the same
      <?xml version="1.0" encoding="utf-8"?>
      <content>
      <page location="home" >
      <image src="loadxmlpic.jpg"></image>
      </page>
      <page location="about">
      <title>About Page</title>
      <text>More about this site.</text>
      </page>
      <page location="contact">
      <title>Contact Us</title>
      <text>Get in touch!</text>
      </page>
      </content>
      quote:

      Text


      I want the loadxml.jpg defined in the first node to get loaded when the button Home page is clicked. Plz let me kn the correct code.