How to get DataProvider API functions without the List component

Lee, lee da dee… lee da dee…
rave, rave, rave…

Do you want the DataProvider API functions for your array’s without having to include the List component in your SWF for them? Then do:

import mx.controls.listclasses.DataProvider

class MyClass
{
        static var mixIt:Boolean = DataProvider.Initialize(Array);
}

The DataProvider.Initialize function basically adds the DataProvider functions to the Array’s prototype. I’m writing my own class that adds and removes items from an array, but they aren’t really item’s, but they follow the same pattern, so I figured I wouldn’t re-invent the wheel.

public function addCowAt(index:Number, someCow:Object):Void
{
        cow_array.addItemAt(index, someCow);
}

3 Replies to “How to get DataProvider API functions without the List component”

  1. Why is it I only ever find this stuff after struggling for an hour to work out the solution! :p Thanks for the info, I wonder why MM have also provided a DataProvider “type” class with the same name, I’m using DataProvider as per your example, but also wanted to use:

    import mx.data.types.DataProvider;

    …in the same app, but of course, no go. Any ideas would be great great great!

    Rich

  2. Cheers! I was getting frustrated because I was trying to import both DataProvider classes (not using any of the components that initialize Array with DataProvider) and wanted to type check with the 2nd DataProvider class. All sorted now, thanks again,

    Rich

Comments are closed.