3 Replies Latest reply on Mar 12, 2010 6:33 PM by David_F57

    xml problems

    MrSchieska Level 1

      well this is my first try with flash builder 4 so it would likley be a dumb mistake XD


      this is my xml:
      <?xml version="1.0" encoding="utf-8"?>
         <date day="01" month="januari" year="2010" />
         <summary>lalalalala </summary>
         <client> client 1 </client>
         <linkentry label="text" href="http://www.google.nl"/>


      and this my main.mxml:
      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"

               import mx.collections.ArrayCollection;
               import mx.rpc.events.ResultEvent;

               private var ac:ArrayCollection;
               private function service_resultHandler(event:ResultEvent):void{
                  ac = event.result.entry;

               <s:HTTPService id="service" url="http://schieska.comlu.com/test.xml" result="service_resultHandler(event)" />
         <mx:Image x="154" y="152" width="166" height="187" source="{img1}" />
         <mx:Text text="{title}" x="207" y="95" />


      when I run it i get 2 errors:
      Description   Resource   Path   Location   Type
      1120: Access of undefined property img1.   xmltest.mxml   xmltest/src   line 24   Flex Problem
      1120: Access of undefined property title.   xmltest.mxml   xmltest/src   line 25   Flex Problem


      what am i doing wrong?


      greetz Schieska

        • 1. Re: xml problems
          David_F57 Level 5



          Your first problem is that img1 and title don't exist until after you have loaded the xml file, you can't populate your image or text components until you have retrieved the data.


          So after the xml is retrieved you can populate the text field(in the result handler), Then you need to retrieve the image with a url loader so that you can populate the image component. By simply giving the image name to the image component will result in the component recieving no content so the correct process is to get the data for the image once you have that data pass it to the image component.




          1 person found this helpful
          • 2. Re: xml problems
            MrSchieska Level 1



            I think that I know what you mean, but I can't seem to get it to work.

            could you please give me an example of how I could do this.



            • 3. Re: xml problems
              David_F57 Level 5



              The following example is similar to what you want, the difference is that it loops through the xml once it has retrieved it and downloads the images into an array.


              I have enabled source view (right click on the swf to get its source code)






              Just a note this was done using an updated sdk (dec' 09) so it would be better to get a recent/nightly build of the flex 4 sdk if you want to copy the project into your Flashbuilder IDE.