I've created an add-on to Alex Uhlman observe tag
(http://weblogs.macromedia.com/auhlmann/archives/2006/09/using_binding_s.cfm)
that not only monitors the settings of a collection but also tracks
changes in it.

package com.adobe.ac
{
        import mx.events.CollectionEvent;
        import flash.events.Event;
                
        public class ObserveCollection extends Observe
        {
                
                private var _source : Object;
                
                
                override public function get source() : Object
                {
                        return _source;
                }
        
                public override function set source( value : Object ) : void
                {       
                        if (_source != null)
                        
_source.removeEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangeHandler);

                        _source = value;
                
_source.addEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangeHandler);

                        isSourceInitialized = true;     
                        if( isHandlerInitialized && isSourceInitialized )
                        {
                                callHandler();
                        }
                }

                private function collectionChangeHandler (event:Event) : void 
                {
                        
                        callHandler();
                }               
        }
}

Different approach, same result. :)

Dennis







--- In flexcoders@yahoogroups.com, "dbronk" <[EMAIL PROTECTED]> wrote:
>
> I have a VO:
> 
> [Bindable]
> public class Product
> {
> public var productName : String;
> // several more attributes here
> }
> 
> I place a large number of Products in my Cairngorm Singleton
> SellModelLocator in var productList : ArrayCollection;
> 
> The entire SellModelLocator is declared Bindable.  In one of my mxml
> views I have the following:
> 
> <mx:Binding source="SellModelLocator.getInstance().productList"
> destination="refreshFilters" />
> 
> I need this binding to execute refreshFilters whenever I add/remove a
> Product to productList as well as when I change an attribute in one of
> the Products contained in productList.  How do I do this?
> 
> The follow will fire the refreshFilters:
> - SellModelLocator.getInstance().productList = new ArrayCollection();
> - SellModelLocator.getInstance().productList = someOtherArrayCollection;
> 
> The following will NOT fire the refreshFilters:
> - SellModelLocator.getInstance().productList.addItem( new Product() );
> -
> Product(SellModelLocator.getInstance().productList.getItemAt(0)).status
> = "ACTIVE";
> 
> Any help on how to do a deep bind would be appreciated.
> 
> Thanks,
> Dale
>


Reply via email to