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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:11:01+00:00 2026-05-12T21:11:01+00:00

In my flex application I use services a lot. I need them to update

  • 0

In my flex application I use services a lot. I need them to update my data in the application, so call them quite often. Currently I implemented it in the following way:

1) There is a service provider (AMFLoader class)
2) And response handler (Responder class)

The code looks like this:

public function AMFLoader(url:String):void
{
     gateway = new NetConnection();
     gateway.connect(url);
}

public function callAMFLoader(serviceName:String, param:String,  resultHandler:AMFResultHandler):void
{
     gateway.addEventListener(IOErrorEvent.IO_ERROR, resultHandler.onIENetError);
     gateway.addEventListener(NetStatusEvent.NET_STATUS, resultHandler.onNetStatus);
     responder = new Responder(resultHandler.onSuccess, resultHandler.onFalse);
     gateway.call(serviceName,responder, param);

}

and Result handler class:

public class AMFResultHandler
{
    public function AMFResultHandler()
    {
    }


    public function onSuccess(result:*):void
    {
        trace("Result from basic AMF Result handler on success: " + result);
    }

To make a call to a service I extend basic Result handler class, and make custom functions to process results. Usually on the latest stages, I’m binding data received from the service to the global variables which I defined in the main application, and then use it in other classes.

Currently I noticed that this is quite an annoying thing to use global variables, not sure if it’s a good programming style to do it.
For example when I tried to refactor my code, I noticed that it’s sometimes hard to understand who and when (and why), populated data there.

Maybe you can suggest a way of storing the data from services calls. The main thing I am failing to understand is that we can’t just create a method, e.g. getData, and call it somewhere in the application, because calling service and storing the data are different things (as data is received only on some event)….

Thanks in advance.

  • 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-12T21:11:01+00:00Added an answer on May 12, 2026 at 9:11 pm

    What you’re asking about is one of the main purposes of an MVC framework. Specifically your talking about the Model or data interface. What you should do, if you don’t want to go with a full blown framework just yet, is create 2 classes.

    1) DataObject

    2) DataModel

    where “Data” is replaced with something intuitive like User or Products. In the DataObject you keep only properties of the data and similarly it is the only place where data is assumed to be correct. The DataObject though is only accessed directly through the DataModel. Inside the data model you keep all the getters and setters of the DataObject as well as any remote service calls you need to populate the DataObject.

    This is just the beginning of MVC style application development and if you truly want to move on to more flexible, manageable code you should consider going with a full blown framework. Two that i recomend are:

    1) Swiz ( http://swizframework.org/ ) : a super simple event driven framework that really leverages the power of flex.

    2) PureMVC ( http://puremvc.org/ ) : an easy to understand MVC code structure that emphasizes code decoupling and strict MVC architecture.

    I say start with one of those two and you’ll be well on your way to becoming a better flex developer.


    a couple great tutorials:

    swiz: http://vimeo.com/7166397

    pureMVC: http://active.tutsplus.com/tutorials/workflow/understanding-the-puremvc-open-source-framework/

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

Sidebar

Related Questions

No related questions found

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.