Package | fl.data |
Class | public class DataProvider |
Inheritance | DataProvider ![]() |
A data provider is a linear collection of items that serve as a data source--for
example, an array. Each item in a data provider is an object or XML object that contains one or
more fields of data. You can access the items that are contained in a data provider by index, by
using the DataProvider.getItemAt()
method.
Property | Defined by | ||
---|---|---|---|
length : uint [read-only]
The number of items that the data provider contains.
| DataProvider |
Method | Defined by | ||
---|---|---|---|
DataProvider(value:Object = null)
Creates a new DataProvider object using a list, XML instance or an array of data objects
as the data source.
| DataProvider | ||
addItem(item:Object):void
Appends an item to the end of the data provider.
| DataProvider | ||
addItemAt(item:Object, index:uint):void
Adds a new item to the data provider at the specified index.
| DataProvider | ||
addItems(items:Object):void
Appends multiple items to the end of the DataProvider and dispatches
a
DataChangeType.ADD event. | DataProvider | ||
addItemsAt(items:Object, index:uint):void
Adds several items to the data provider at the specified index and dispatches
a
DataChangeType.ADD event. | DataProvider | ||
Creates a copy of the current DataProvider object.
| DataProvider | ||
concat(items:Object):void
Concatenates the specified items to the end of the current data provider.
| DataProvider | ||
getItemAt(index:uint):Object
Returns the item at the specified index.
| DataProvider | ||
getItemIndex(item:Object):int
Returns the index of the specified item.
| DataProvider | ||
invalidate():void
Invalidates all the data items that the DataProvider contains and dispatches a
DataChangeEvent.INVALIDATE_ALL event. | DataProvider | ||
invalidateItem(item:Object):void
Invalidates the specified item.
| DataProvider | ||
invalidateItemAt(index:int):void
Invalidates the item at the specified index.
| DataProvider | ||
merge(newData:Object):void
Appends the specified data into the data that the data provider
contains and removes any duplicate items.
| DataProvider | ||
removeAll():void
Removes all items from the data provider and dispatches a
DataChangeType.REMOVE_ALL
event. | DataProvider | ||
removeItem(item:Object):Object
Removes the specified item from the data provider and dispatches a
DataChangeType.REMOVE
event. | DataProvider | ||
removeItemAt(index:uint):Object
Removes the item at the specified index and dispatches a
DataChangeType.REMOVE
event. | DataProvider | ||
replaceItem(newItem:Object, oldItem:Object):Object
Replaces an existing item with a new item and dispatches a
DataChangeType.REPLACE
event. | DataProvider | ||
replaceItemAt(newItem:Object, index:uint):Object
Replaces the item at the specified index and dispatches a
DataChangeType.REPLACE
event. | DataProvider | ||
sort(... sortArgs):*
Sorts the items that the data provider contains and dispatches a
DataChangeType.SORT
event. | DataProvider | ||
sortOn(fieldName:Object, options:Object = null):*
Sorts the items that the data provider contains by the specified
field and dispatches a
DataChangeType.SORT event. | DataProvider | ||
toArray():Array
Creates an Array object representation of the data that the data provider contains.
| DataProvider | ||
toString():String
Creates a string representation of the data that the data provider contains.
| DataProvider |
Event | Summary | Defined by | ||
---|---|---|---|---|
Dispatched after the data is changed. | DataProvider | |||
Dispatched before the data is changed. | DataProvider |
length | property |
length:uint
[read-only]The number of items that the data provider contains.
Implementation public function get length():uint
DataProvider | () | constructor |
public function DataProvider(value:Object = null)
Creates a new DataProvider object using a list, XML instance or an array of data objects as the data source.
Parametersvalue:Object (default = null ) — The data that is used to create the DataProvider.
|
addItem | () | method |
public function addItem(item:Object):void
Appends an item to the end of the data provider.
Parametersitem:Object — The item to be appended to the end of the current data provider.
|
See also
addItemAt | () | method |
public function addItemAt(item:Object, index:uint):void
Adds a new item to the data provider at the specified index. If the index that is specified exceeds the length of the data provider, the index is ignored.
Parametersitem:Object — An object that contains the data for the item to be added.
|
|
index:uint — The index at which the item is to be added.
|
— The specified index is less than 0 or greater than or equal
to the length of the data provider.
|
See also
addItems | () | method |
public function addItems(items:Object):void
Appends multiple items to the end of the DataProvider and dispatches
a DataChangeType.ADD
event. The items are added in the order
in which they are specified.
items:Object — The items to be appended to the data provider.
|
See also
addItemsAt | () | method |
public function addItemsAt(items:Object, index:uint):void
Adds several items to the data provider at the specified index and dispatches
a DataChangeType.ADD
event.
items:Object — The items to be added to the data provider.
|
|
index:uint — The index at which the items are to be inserted.
|
— The specified index is less than 0 or greater than or equal
to the length of the data provider.
|
See also
clone | () | method |
public function clone():DataProvider
Creates a copy of the current DataProvider object.
ReturnsDataProvider —
A new instance of this DataProvider object.
|
concat | () | method |
public function concat(items:Object):void
Concatenates the specified items to the end of the current data provider.
This method dispatches a DataChangeType.ADD
event.
items:Object — The items to be added to the data provider.
|
See also
getItemAt | () | method |
public function getItemAt(index:uint):Object
Returns the item at the specified index.
Parametersindex:uint — Location of the item to be returned.
|
Object — The item at the specified index.
|
— The specified index is less than 0 or greater than
or equal to the length of the data provider.
|
See also
getItemIndex | () | method |
public function getItemIndex(item:Object):int
Returns the index of the specified item.
Parametersitem:Object — The item to be located.
|
int — The index of the specified item, or -1 if the specified item is not found.
|
See also
invalidate | () | method |
public function invalidate():void
Invalidates all the data items that the DataProvider contains and dispatches a
DataChangeEvent.INVALIDATE_ALL
event. Items are invalidated after they
are changed; the DataProvider automatically redraws the invalidated items.
See also
invalidateItem | () | method |
public function invalidateItem(item:Object):void
Invalidates the specified item. An item is invalidated after it is changed; the DataProvider automatically redraws the invalidated item.
Parametersitem:Object — Item to be invalidated.
|
See also
invalidateItemAt | () | method |
public function invalidateItemAt(index:int):void
Invalidates the item at the specified index. An item is invalidated after it is changed; the DataProvider automatically redraws the invalidated item.
Parametersindex:int — Index of the item to be invalidated.
|
— The specified index is less than 0 or greater than
or equal to the length of the data provider.
|
See also
merge | () | method |
public function merge(newData:Object):void
Appends the specified data into the data that the data provider
contains and removes any duplicate items. This method dispatches
a DataChangeType.ADD
event.
newData:Object — Data to be merged into the data provider.
|
See also
removeAll | () | method |
public function removeAll():void
Removes all items from the data provider and dispatches a DataChangeType.REMOVE_ALL
event.
See also
removeItem | () | method |
public function removeItem(item:Object):Object
Removes the specified item from the data provider and dispatches a DataChangeType.REMOVE
event.
item:Object — Item to be removed.
|
Object — The item that was removed.
|
See also
removeItemAt | () | method |
public function removeItemAt(index:uint):Object
Removes the item at the specified index and dispatches a DataChangeType.REMOVE
event.
index:uint — Index of the item to be removed.
|
Object — The item that was removed.
|
— The specified index is less than 0 or greater than
or equal to the length of the data provider.
|
See also
replaceItem | () | method |
public function replaceItem(newItem:Object, oldItem:Object):Object
Replaces an existing item with a new item and dispatches a DataChangeType.REPLACE
event.
newItem:Object — The item to be replaced.
|
|
oldItem:Object — The replacement item.
|
Object — The item that was replaced.
|
— The item could not be found in the data provider.
|
See also
replaceItemAt | () | method |
public function replaceItemAt(newItem:Object, index:uint):Object
Replaces the item at the specified index and dispatches a DataChangeType.REPLACE
event.
newItem:Object — The replacement item.
|
|
index:uint — The index of the item to be replaced.
|
Object — The item that was replaced.
|
— The specified index is less than 0 or greater than
or equal to the length of the data provider.
|
See also
sort | () | method |
public function sort(... sortArgs):*
Sorts the items that the data provider contains and dispatches a DataChangeType.SORT
event.
... sortArgs — The arguments to use for sorting.
|
* — The return value depends on whether the method receives any arguments.
See the Array.sort() method for more information.
This method returns 0 when the sortOption property
is set to Array.UNIQUESORT .
|
See also
sortOn | () | method |
public function sortOn(fieldName:Object, options:Object = null):*
Sorts the items that the data provider contains by the specified
field and dispatches a DataChangeType.SORT
event.
The specified field can be a string, or an array of string values that
designate multiple fields to sort on in order of precedence.
fieldName:Object — The item field by which to sort. This value can be a string
or an array of string values.
|
|
options:Object (default = null ) — Options for sorting.
|
* — The return value depends on whether the method receives any arguments.
For more information, see the Array.sortOn() method.
If the sortOption property is set to Array.UNIQUESORT ,
this method returns 0.
|
See also
toArray | () | method |
public function toArray():Array
Creates an Array object representation of the data that the data provider contains.
ReturnsArray — An Array object representation of the data that the data provider contains.
|
toString | () | method |
public override function toString():String
Creates a string representation of the data that the data provider contains.
ReturnsString — A string representation of the data that the data provider contains.
|
dataChange | event |
fl.events.DataChangeEvent
fl.events.DataChangeEvent.DATA_CHANGE
Dispatched after the data is changed.
Defines the value of the type
property of a dataChange
event object.
This event has the following properties:
Property | Value |
---|---|
bubbles | false |
cancelable | false ; there is no default behavior to cancel. |
changeType | Identifies the type of change that was made. |
currentTarget | The object that is actively processing the event object with an event listener. |
endIndex | Identifies the index of the last changed item. |
items | An array that lists the items that were changed. |
startIndex | Identifies the index of the first changed item. |
target | The object that dispatched the event. The target is
not always the object listening for the event. Use the currentTarget
property to access the object that is listening for the event. |
See also
preDataChange | event |
fl.events.DataChangeEvent
fl.events.DataChangeEvent.PRE_DATA_CHANGE
Dispatched before the data is changed.
Defines the value of the type
property of a preDataChange
event object. This event object is dispatched before a change is made to component data.
This event has the following properties:
Property | Value |
---|---|
bubbles | false |
cancelable | false ; there is no default behavior to cancel. |
changeType | Identifies the type of change to be made. |
currentTarget | The object that is actively processing the event object with an event listener. |
endIndex | Identifies the index of the last item to be changed. |
items | An array that lists the items to be changed. |
startIndex | Identifies the index of the first item to be changed. |
target | The object that dispatched the event. The target is
not always the object listening for the event. Use the currentTarget
property to access the object that is listening for the event. |
See also