You're initializing the acUser collection when the singleton is created and
adding a listener, which is fine. However, when you're getting the results
back, you're changing the acUser collection reference to a different
ArrayCollection

GlobalVars.instance.acUser = event.result as ArrayCollection;

So your singleton still has a listener registered on the original
ArrayCollection, but your singleton model now contains a reference to the
new ArrayCollection returned from the service. To keep your references
pointing to the same ArrayCollection and still get the COLLECTION_CHANGE,
you could play games like this:

GlobalVars.instance.acUser.source = ArrayCollection(event.result).source;
GlobalVars.instance.acUser.refresh();

In that you're swapping out the underlying Array the collection is wrapped
around, and then calling refresh will dispatch teh COLLECTION_CHANGE, firing
any bindings and calling your listener code.

On Thu, Jul 17, 2008 at 8:43 AM, Scott <[EMAIL PROTECTED]> wrote:

>    First thanks for all your help guys.  I'm making nice strides learning
> this language quickly.
>
>
>
> I'm working with events now.  I created an arrayCollection to capture a
> query from coldfusion.  I have the data being dumped into this variable just
> fine (I can do a combobox on it and see all of it).  Now what I want to do
> is set some variables based on these items.  I created an event to watch the
> arrayCollection which would run a function to reset the variables
> automatically.  Here's what I did:
>
>
>
>
>
> This is all within a singleton class…
>
>
>
> Created the [Bindable]acUser array collection
>
> [Bindable] public var acUser:ArrayCollection = new ArrayCollection();
>
>
>
> Created an init() function to set up the event handler:
>
>       *private* *function* init():*void*
>
>       {
>
>       acUser.addEventListener(CollectionEvent.COLLECTION_CHANGE,
> acUser_collectionChange);
>
>       }
>
>
>
> Created a function to set the variables if the event hit:
>
>       *private* *function* acUser_collectionChange(event:CollectionEvent):
> *void*
>
>       {
>
>             strEMail = ObjectUtil.toString(acUser.getItemAt(0).strEMail);
> (not sure if this call is correct –yet-)
>
>             *trace*(strEMail);
>
>       }
>
>
>
> Modified the header for the page to run the init() function
>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>
>       creationComplete="init()"
>
>       xmlns="*"
>
>       xmlns:controllers="com.cfgenerated.controllers.*"
>
>     xmlns:login="com.cfgenerated.views.login.*"
>
>       layout="absolute"
>
>       currentState="NotLoggedIn">
>
>
>
>
>
> This should be all I need to do, right?
>
>
>
> When I push the data into the singleton:
>
>
>
> GlobalVars.instance.acUser = event.result as ArrayCollection;
>
>
>
> The event does not fire.  Any ideas?
>
>
>
>
>
> TIA!
>  
>

Reply via email to