3 Replies Latest reply on Nov 11, 2009 11:49 AM by brian914

    s:HTTPService not loading?

    brian914 Level 1

      I am learning Flash Builder and am having a hard time figuring out this issue. For some reason, my HTTPService is not loading my xml document and I can't figure out why. I think I am sure I am requesting it from the right location.

       

      Thanks a lot for any help with this!

       

      Here is what I have:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application 
           xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/halo" 
           applicationComplete="app1_applicationCompleteHandler(event)"
           minWidth="1024" minHeight="768">
      
           <!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
           <fx:Script>
                <![CDATA[
                
                     // import statements ----------------------------------------
      
                     import mx.events.FlexEvent;
                     import mx.rpc.events.FaultEvent;
                     import mx.rpc.events.ResultEvent;
                     // event handlers -------------------------------------------
      
                     protected function thumbXML_resultHandler(event:ResultEvent):voi
                     {
                          trace(thumbXML.lastResult.thumbs.thumbHolder[0].imag;
                     }
      
                     protected function thumbXML_faultHandler(event:FaultEvent):void
                     {
                          trace("XML did not load: " + event.toString());
                     }
      
                     protected function app1_applicationCompleteHandler(event:FlexEvent):void
                     {
                          thumbXML.send();
                     }
      
                ]]>
           </fx:Script>
           <!-- Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
           <fx:Declarations>
                <s:HTTPService id="thumbXML"
                     request="xml/thumbs.xml"
                     result="thumbXML_resultHandler(event)"
                     fault="thumbXML_faultHandler(event)"/>
           </fx:Declarations>
      
           <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      </s:Application>
      
        • 1. Re: s:HTTPService not loading?
          Peter deHaan Level 4

          This works for me:

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:s="library://ns.adobe.com/flex/spark" 
                        xmlns:mx="library://ns.adobe.com/flex/halo" 
                        applicationComplete="app1_applicationCompleteHandler(event);">
              <!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
              <fx:Script>
                  <![CDATA[
                      import mx.events.FlexEvent;
                      import mx.rpc.events.FaultEvent;
                      import mx.rpc.events.ResultEvent;
                      // event handlers -------------------------------------------
                      protected function thumbXML_resultHandler(evt:ResultEvent):void {
                          trace(thumbXML.lastResult.thumbs.thumbHolder[0].imag);
                      }
                      protected function thumbXML_faultHandler(evt:FaultEvent):void {
                          trace("XML did not load: " + evt.toString());
                      }
                      protected function app1_applicationCompleteHandler(evt:FlexEvent):void {
                          thumbXML.send();
                      }
                  ]]>
              </fx:Script>
              <!-- Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
              <fx:Declarations>
                  <s:HTTPService id="thumbXML"
                                url="xml/thumbs.xml"
                                result="thumbXML_resultHandler(event);"
                                fault="thumbXML_faultHandler(event);"/>
              </fx:Declarations>
              <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
          </s:Application>
          

           

           

          Where thumbs.xml is something like this:

           

           

           

          <thumbs>
              <thumbHolder>
                  <imag>(1)One</imag>
              </thumbHolder>
              <thumbHolder>
                  <imag>(2)Two</imag>
              </thumbHolder>
              <thumbHolder>
                  <imag>(3)Three</imag>
              </thumbHolder>
              <thumbHolder>
                  <imag>(4)Four</imag>
              </thumbHolder>
              <thumbHolder>
                  <imag>(5)Five</imag>
              </thumbHolder>
              <thumbHolder>
                  <imag>(6)Six</imag>
              </thumbHolder>
          
          </thumbs>
          
          

           

          Peter

          • 2. Re: s:HTTPService not loading?
            brian914 Level 1

            Did you make changes to my code? I am wondering if there might be something screwed up with my code?

            • 3. Re: s:HTTPService not loading?
              brian914 Level 1

              Thanks a lot for having a look, sorry forgot that in the last post!