Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9130125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:54:06+00:00 2026-06-17T07:54:06+00:00

I am clear about how to use HTTP Service in flex but i want

  • 0

I am clear about how to use HTTP Service in flex but i want to separate the functionality of calling service and getting response of the service in a different ActionScript class. So does anyone know how can i return the response of the HTTP service in flex ?

for e.g.

IN UTILITY class i want to have one method to which i will give one URL and it will give me the data obtained from that location. That’s it. consider the following code snippet. reference code taken from could not be able to create http service programmitically in flex

        private function callService():void
        {
            var requestObj:Object = {};
            requestObj.q = cityName.text.toString();
            requestObj.format = FORMAT;
            requestObj.num_of_days = cNUMBER_OF_DAYS;
            requestObj.key = API_KEY;

            var weatherService:HTTPService = new HTTPService();
            weatherService.url = BASE_URL;
            weatherService.resultFormat = "object";
            weatherService.showBusyCursor = true;
            weatherService.request = requestObj;
            weatherService.addEventListener(ResultEvent.RESULT , weatherService_resultHandler);
            weatherService.addEventListener(FaultEvent.FAULT, weatherService_faultHandler);
            weatherService.send();
        }

        protected function weatherService_resultHandler(event:ResultEvent):void
        {
            trace("got result");
            **//WANT TO GIVE THIS RESULT BACK TO THE CALLER. SINCE RETURN TYPE OF 
            //METHOD IS VOID I CANNOT RETURN ANYTHING FROM HERE. HOW TO MAKE THIS
            //METHOD TO RETURN DATA?**
        }

        protected function weatherService_faultHandler(event:FaultEvent):void
        {
            trace("got fault");
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:54:08+00:00Added an answer on June 17, 2026 at 7:54 am

    There are several solutions depending on the architecture of your project. The main idea is to fire the event (or call callback) when service receive response and handle it in the caller. The simplest way in your example is to return the weatherService object in the callService method and add the same listeners in the caller (ResultEvent.RESULT and FaultEvent.FAULT). The minus of this solution is that you have to parse the raw server response in caller rather than to work with some parsed value objects but as I noticed all depends on your project data flow.

    UPD: the example of callback usage:

    //map for storing the {service:callback} linkage
    private var callbacks:Dictionary = new Dictionary(true);
    /*
    callback is a function like: function(success:Boolean, data:Object):void
    */
    private function callService(callback:Function):void
    {
        var requestObj:Object = {};
        requestObj.q = cityName.text.toString();
        requestObj.format = FORMAT;
        requestObj.num_of_days = cNUMBER_OF_DAYS;
        requestObj.key = API_KEY;
    
        var weatherService:HTTPService = new HTTPService();
        weatherService.resultFormat = "object";
        weatherService.showBusyCursor = true;
        weatherService.request = requestObj;
        weatherService.addEventListener(ResultEvent.RESULT, weatherService_handler);
        weatherService.addEventListener(FaultEvent.FAULT, weatherService_handler);
        var token:AsyncToken = weatherService.send();
    
        var obj:Object = {callback:callback, service:weatherService};
        callbacks[token.message.messageId] = obj;
    }
    
    protected function weatherService_handler(event:Event):void
    {
        var success:Boolean = event.type == ResultEvent.RESULT;
        var token:AsyncToken = success ? ResultEvent(event).token : FaultEvent(event).token;
    
        var obj:Object = callbacks[token.message.messageId]
        var service:HTTPService = obj.service;
        service.removeEventListener(ResultEvent.RESULT , weatherService_handler);
        service.removeEventListener(FaultEvent.FAULT, weatherService_handler);
    
        var data:Object = success ? ResultEvent(event).result : FaultEvent(event).fault;
        var callback:Function = obj.callback;
        delete callbacks[event.target];
    
        callback(success, data);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was learning about property, I read various documents but still not clear about
I'm reading Metaprogramming Ruby and just want to clear something up about the following
Lots of information on NSDates about the place, but I haven't found a clear
I'm thinking about trying MongoDB to use for storing our stats but have some
Sorry if title is not too clear but I think it's about right. NEhow,
I want to access a full rest service with basic http auth running. However
If i want to use WebAPI as a service to connect to multiple databases
I am not too clear about the autorelease message... When autorelease is sent to
I am not very clear about this code outer is a class and the
I'm not too clear about this and neither are the docs. When I'm creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.