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