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 );
}
}