Let me correct that last statement...
I do -not- see the acUser in the control-space selection items. I see the original named variable and other functions but I also see some functions that no longer exist. Why isn't Flex updating that list? ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Scott Sent: Thursday, July 17, 2008 5:24 PM To: flexcoders@yahoogroups.com Subject: {Disarmed} Re: [flexcoders] arrayCollection event COLLECTION_CHANGE issues? When I do that I get an error that the property is not defined. I can do the control space and see that FB is seeing all of the items along the path of GlobalVars.instance.acUser.source but the instant I save it the error "access of possibly undefined property accuser through a reference with static type com.cfgenerated.models.GlobalVars. This is my .as singleton class: public class GlobalVars { private static var classInstance:GlobalVars = null; private static var constructorLocked:Boolean = true; public var objUser:Object = new Object(); public function GlobalVars() { if( constructorLocked ) { throw new Error( "Cannot open another instance of GVs" ); } } public static function get instance():GlobalVars { if( classInstance == null ) { constructorLocked = false; classInstance = new GlobalVars(); constructorLocked = true; } return classInstance; } } And this is my call to create the singleton instance: [Bindable] public var acUser:ArrayCollection = new ArrayCollection(); Any ideas? Thanks sj ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Gold Sent: Thursday, July 17, 2008 8:45 AM To: flexcoders@yahoogroups.com Subject: {Disarmed} Re: [flexcoders] arrayCollection event COLLECTION_CHANGE issues? 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] <mailto:[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 <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! -- This message has been scanned for viruses and dangerous content by MailScanner <http://www.mailscanner.info/> , and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner <http://www.mailscanner.info/> , and is believed to be clean.