3 Replies Latest reply on Sep 29, 2008 5:55 AM by SujitG

    Help with HTTPService

    hsvtj
      Hi,
      im still getting my head around Flex. I have just completed a tutorial on a simple RSS feed reader, and i was wondering..

      how can i get the HTTPService to load from a user defined URL, instead of one hard coded in the flex code?

      for example, the user types the URL of an xml feed into a text box, and the HTTPService reads that, and gets the feeds from that URL, so the user can view RSS feeds from anywhere they chose?

      eventually, the application will have saved URLs for a bunch of the users favourite artists (music) and while the user listens to the music, they stay up to date with the latest news as well.

      any help would be appreciated. thank you
      Trent
        • 1. Help with HTTPService
          BluDragon777
          You should be able to create a bindable variable and set it to the value of your text input and then use that variable in a binding expression as the url of your service.

          Please note that I am a newbie who has only been doing this a couple of weeks so if the following code does not work please don't shoot me.

          Edit: For some reason the "Attach Code" thing is not showing up so here it is:

          <mx:Script>
          [Bindable] public var myServiceURL:String;

          public function getServiceURL():void
          {
          myServiceURL = myTextInput.text;
          }
          </mx:Script>
          <mx:HTTPService url="{myServiceURL}"/>
          <mx:TextInput id="myTextInput" onChange="getServiceURL"/>
          • 2. Re: Help with HTTPService
            SujitG Level 2
            Hi,

            All you need to do is to set the new URL to the HTTPService and invoke the send() method of the HTTPService when the user clicks the button. Please find details on how to invoke a HTTPService in ActionScript below.

            var service:HTTPService = new HTTPService();
            service.url = <your url>;
            service.method = "GET";
            service.addEventListener("result", httpResult);
            service.addEventListener("fault", httpFault);
            service.send();

            Hope this helps.
            • 3. Re: Help with HTTPService
              SujitG Level 2
              Hi,

              All you need to do is to set the new URL to the HTTPService and invoke the send() method of the HTTPService when the user clicks the button. Please find details on how to invoke a HTTPService in ActionScript below.

              var service:HTTPService = new HTTPService();
              service.url = <your url>;
              service.method = "GET";
              service.addEventListener("result", httpResult);
              service.addEventListener("fault", httpFault);
              service.send();

              Hope this helps.