On Fri, Apr 18, 2008 at 6:50 PM, Tracy Spratt <[EMAIL PROTECTED]> wrote:
> dataprovider again, right?  I had assumed that implementing a dataprovider
> would make updates to the UI cleaner (not having to re-create all items),
> but I could be wrong on that assumption- don't know yet.
>

I like to do it like this:

[Bindable]
public function set dataProvider(value :Object) :void {

    if (_dataProvider) {
        _dataProvider.removeEventListener(
            CollectionEvent.COLLECTION_CHANGE,
            onDataChange,
            false
        );
    }

    _dataProvider   =   (value is Array)    ? new
ArrayCollection(value as Array)
                    :   (value is IList)    ? IList(value)
                    :   (value is XMLList)  ? new
XMLListCollection(value as XMLList)
                    :   new ArrayCollection()
                    ;

    _dataProvider.addEventListener(
        CollectionEvent.COLLECTION_CHANGE,
        onDataChange,
        false,
        0,
        true
    );

    _dataChanged = true;

  //// etc. etc. etc.

Reply via email to