i just can not give a solution to your first question cuz i couldn't understand it. (sth must be going wrong in your code)
anyway;
here is a better way to handle shared data; a MODEL .

model is a singleton class that generally keeps shared data of your applicaiton.

it should look like ; and you MUST alway call getInstance() to reach it...

like , Model.getInstance().arrayCollection

public class Model{
   private static var instance:Model ;

   public var arrayCollection:ArrayCollection();
   public var foo:Foo; //etc etc ...

   public static function getInstance(){
      if(instance == null )
         instance = new Model();
      return instance;
   }
   public function Model(){
      if(instance != null); //ERROR!!!!!!!!!!!
   }
}

by the way; i wrote it here; there may be a syntax error ...

wish it helps...

aceoohay wrote On 11/24/2007 06:58 PM:

The following is in flexbuilder 2, AS 3.

I have an application that I am building with modules using
NetConnection to access the server. I want to centralize the routines
that get data from the DB for Combo Boxes and the like because I want
to reuse the data returned.

In the parentApplication, I created my function to query and handle
the result, storing the data in a public arrayCollection. In the
module, I access the data by setting the dataprovider to
parentApplication.myArrayCollection. Due to the asynchronous nature
of Flex the data does not appear the first time the module displays
but does if I redisplay the module.

My solution which does not work was to do;

parentApplication.myArrayCollection.addEventListener
(CollectionEvent.COLLECTION_CHANGE,LoadLists);

where LoadLists is a function that sets the dataprovider for the
combobox. LoadLists never gets executed. Being the resourceful
individual I decided to try to force the event by inserting the
following line in my result handler in the parentApplication;

myArrayCollection.dispatchEvent(new CollectionEvent
(mx.events.CollectionEvent.COLLECTION_CHANGE));

This still does not force the event to occur.

Is this a bug, or what am I doing wrong?

A secondary question is;

What is the best way to handle static (mostly) data for combo boxes
so that;

a) It is queried only when needed and
b) Stored at the client for the current session to reduce DB hits?

Paul


Reply via email to