I have been building an application with binding and observers. I have found situations where things were not happening, but these were usually due to some fault in what I wanted to happen. I have not tried to trap changes to an array collection. But my approach would be to simplify the logic. Using your code that works,
I would change the observer: <adobe.ac:Observe source="{ model.aSpecialBooleanVariable }" handler="{ handler }" value="{true}"/> In the function collectionChangeHandler: model.aSpecialBooleanVariable = true; In function handler: model.aSpecialBooleanVariable = false This last part is needed as the observer is only fired when the value changes to true, if the value is already true, and is again set to true, the observer does not recognize this as a change. Try this, it simplifies the firing logic. Trying to capture changes to a collection directly is a black box, this includes adding, deleting items in a collection and changing the value of an item in a collection. Andrew --- In flexcoders@yahoogroups.com, "sethelijahroot" <[EMAIL PROTECTED]> wrote: > > Hi all, > > Having some questions about how best to implement this. So far, I'm > not having much success. > > (I'll be using Paul Williams Observe tag as extended by Alex Uhlmann ) > > I can't get the handler function to trigger, because the source is not > dispatching a proper event. I can listen to the events in my Class, > and using ArrayCollection.addItem dispatches just fine. > > The problem lies in translating that eventListener into something the > Observe tag can see as an Event("changed") or something similar. > > Help! > > <mxml > creationComplete="runTest()"> > > <mx:Script> > private var model:Model = Model.getInstance(); > > private function runTest():void > { > // This should trigger the observe tag to run the handler > model.someWrappedArrayCollectionInstance.addSpecificDataTypeObj( {} ); > } > > private function handler( myList:* ):void > { > // THIS IS WHAT I CAN'T GET TO TRIGGER!! > } > </mx:Script> > > <adobe.ac:Observe > source="{ model.someWrappedArrayCollectionInstance }" > handler="{ handler }" /> > > </mxml> > _________________________________________________ > > import mx.events.CollectionEvent; > public class WrappedArrayCollection > { > private var collection:ArrayCollection = new ArrayCollection([]); > > public function WrappedArrayCollection() > { > collection.addEventListener( CollectionEvent.COLLECTION_CHANGE, > collectionChangeHandler ); > } > > private function collectionChangeHandler():void > { > trace("this part works fine"); > // Should i dispatch an event here for the binding to trigger? > } > > public function addSpecificDataTypeObj( obj:SpecificDataType ):void > { > collection.addItem( obj ); > } > } >