views:

133

answers:

2

Hi,

We are using an XML file as an external configuration file for several parameters in our application (including default values for UI components and properties values of some service layer objects). The idea is to be able to load the XML configuration file before the flex application initializes any of its components. This is crucial because XML loading is processed a-synchronously in flex, which can potentially cause race-conditions in the application.

For example: the configuration file holds the endpoint URL of a web service used to obtain data from the server. The URL resides in the XML because we want to allow our users to alter the endpoint URL according to their environment. Now because the endpoint URL is retrieved only after the XML has been completely loaded, some of the application's components might be invoking operations on this web service before it is initialized with the correct endpoint. The trivial solution would have been to suspend the initialization of the application until the complete event is dispatched by the loader. But it appears that this solution is far from being trivial. I haven't found a single solution that allows me to load the XML before any other object in the application.

Can anyone advice or comment on this matter?

Regards, Shahar

A: 

+1. I am also looking at the feasibility of a similar approach - link to my question - http://stackoverflow.com/questions/2658614/connecting-my-flex-application-to-restlet-webservices

Vatsala
A: 

You cannot have synchronous operations, and in this case I would choose the following approach: after your application is dispatching the creation complete event load the xml. All the user interactions which require data loaded from the xml are disabled and all the other background operation are not yet launched.

After the xml is loaded dispatch an event to signal this thing. The event handler should create the remote objects, web services etc, enable the UI actions, or run the I/O operations which are not related to UI interactions.

Cornel Creanga