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 7029889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:35:52+00:00 2026-05-28T00:35:52+00:00

I have an as3 class that I use for communicating with my Zend_AMF endpoint:

  • 0

I have an as3 class that I use for communicating with my Zend_AMF endpoint:

package test
{
    import flash.events.Event;

    import mx.rpc.AbstractOperation;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;

    [Bindable]
    [RemoteClass(alias="Request")]

    public class Request
    {
        public var url:String = '';

                    //There are a lot more properties, but I have removed them for brevity

        public function Request(url:String){
            this.url = url;
        }

        public function send():void{

            //Create the remoting object
            var remotingObject:RemoteObject = new RemoteObject('test');
            remotingObject.endpoint = "http://site.com/endpoint.php";
            remotingObject.showBusyCursor = true;

            //Send it
            remotingObject.source = this.url;
            var op:AbstractOperation = remotingObject.getOperation(null);

            op.addEventListener(ResultEvent.RESULT, result);
            op.send(this);
        }

        private function result(event:ResultEvent){
            this.dispatchEvent(event);
        }
    }
}

To use it I do the following:

var request:Request = new Request('someRemotingCommand');
request.addEventListener(ResultEvent.RESULT, catchEvent);
request.send();

public function catchEvent(event:ResultEvent):void{
    var result:Response = event.result as Response; //Get result as my response object
    trace(result.responseText);
}

All of this works fine, but it takes a lot of work to use it. I always expect a Response object when calling send() on my request.

Ideally I would like to be able to call request.send() and have it return a Response object directly and not having to deal with a listener:

var result:Response = request.send();

Is this possible? If so, how can I go about doing this?

  • 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-05-28T00:35:53+00:00Added an answer on May 28, 2026 at 12:35 am

    there is a time that elapses or code that needs to complete between an asynchronous event starting and responding.

    The as code is not doing anything other that listening for the event to come back, it wouldn’t make sense to hang while it is waiting.

    If writing all the extra code is too much work for every event-response pair, create a factory class that will handle event creation and removal that would simplify it to one line, but all you’re doing is hiding the event handlers, which you can’t really avoid when it comes to asynchronous communication.


    edit

    You could create a class that bundles this into one abstract class, and different classes stemming from this class would handle different commands and responses differently.

    var request:Request = new Request('someRemotingCommand');
    request.addEventListener(ResultEvent.RESULT, catchEvent);
    request.send();
    
    public function catchEvent(event:ResultEvent):void{
        var result:Response = event.result as Response; //Get result as my response object
        trace(result.responseText);
    }
    

    the utility of such a setup really depends on what you’re trying to achieve though. With asynchronous calls, it’ll always comes back to event handling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in AS3, I have an external class ImageLoader, that loads an image upon request.
I have an AS3 class with some getVideo function. I want to use this
I have a menu that is built using its own AS3 class, when a
I have a content scroller in my Flash CS5/AS3 project that I want to
So I have this pretty basic code in my document class: package { import
I have this abstract factory pattern that I use in as3 that I am
I have two AS3 classes, A and B. Class A contains an ArrayCollection that
I have an AS 3.0 class that loads a JSON file in using a
In AS3, if I have a class such: public class dude { //default value
I have an AS3 project making use of compile time constants. This has worked

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.