Search Flex Components Free

Custom Search

December 9, 2007

Loading data helper classes

Goals

When using back end stuff like database or just simply scripts that save files, use web services or Flash remoting, usually we are involved in the repetitive task of using different LoadVars objects to send and receive data. Once received, we parse and use it. I often get involved in this kind of task and decided to create some wrapper class to avoid repetitive code, and also simplify things. So this simply classes deal with external data: simple variables loaded trough a LoadVars object, data coming from web services or trough Remoting

The three classes implement a queue, so successive calls are dispatched in order, one after the other. This could be no the intention in some situations, so don't use this class if you want to load all at once (using multiple LoadVars object or Pending Calls when using web services or Remoting) In some cases, multiple calls could competes for bandwidth when using large results (some web services returns huge large XML documents or Remoting services large recordsets) so I usually try to resolve in order. The general idea is to make a call and pass a function as the receiver making the process shorter: one call, one function. This doesn't mean that you don't need to parse the results, since each case is different than others, but less code is necessary for the mechanism, and those not comfortable with LoadVars, Web services, Remoting (or just to type much like me) will be happy

Below three movies as example: on the left, one movie loading data using ten successive calls, on the right, a movie loading a list of web services offered by xmethods, and below them the HelloWorld Remoting example using the remotingProvider class

Related Flex Tutorials