0 Replies Latest reply on Mar 28, 2010 1:48 PM by jeffel123

    calling HTTP Service from ActionScript

    jeffel123

      I am trying to move some of my code out of my mxml into seperate action script classes.

       

      Right now I am using the httpservice and simply binding the ResultEvent to a function then can update my ui. Now that I have moved the code out of the UI I don't have the same flexibility.


      Consdier the following actionscript.

       

      package services

      {

           import mx.rpc.events.ResultEvent;

           import mx.rpc.http.mxml.HTTPService;

       

           public class DashBoardService

           {

           public function DashBoardService()

           {

           }

       

           public function getDashBoard():void{

       

                var returnData:XML;

       

                var svc:HTTPService = new HTTPService();

                svc.resultFormat = "e4x";

                svc.showBusyCursor = true;

                svc.method = "GET";

                svc.url="http://localhost/data.xml";

                svc.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void {

       

                //do something here

                });

                svc.send();

           }

           }

      }

       

      Ideally I would like to be able to call getDashBoard and have it return non void with the data from the service. Obviously I can't return returnData because it will be null. Any ideas how I can do this? I suppose I can issue an event from the callback and then handle it elsewhere but it seems like overkill for what I need.