Package | feathers.data |
Class | public class VectorCollection |
Inheritance | VectorCollection starling.events.EventDispatcher |
Implements | IListCollection |
Product Version : | Feathers 3.3.0 |
Vector
in the common IListCollection
API used by many Feathers UI controls, including List
and
TabBar
.
Property | Defined By | ||
---|---|---|---|
filterFunction : Function
A function to determine if each item in the collection should be
included or excluded from visibility through APIs like
length and getItemAt(). | VectorCollection | ||
length : int [read-only]
The number of items in the collection. | VectorCollection | ||
sortCompareFunction : Function
A function to compare each item in the collection to determine the
order when sorted. | VectorCollection | ||
vectorData : Object
The Vector data source for this collection. | VectorCollection |
Method | Defined By | ||
---|---|---|---|
VectorCollection(data:Object = null)
Constructor
| VectorCollection | ||
addAll(collection:IListCollection):void
Adds all items from another collection. | VectorCollection | ||
addAllAt(collection:IListCollection, index:int):void
Adds all items from another collection, placing the items at a
specific index in this collection. | VectorCollection | ||
addItem(item:Object):void
Adds an item to the end of the collection. | VectorCollection | ||
addItemAt(item:Object, index:int):void
Adds an item to the collection, at the specified index. | VectorCollection | ||
contains(item:Object):Boolean
Determines if the specified item is in the collection. | VectorCollection | ||
dispose(disposeItem:Function):void
Calls a function for each item in the collection that may be used
to dispose any properties on the item. | VectorCollection | ||
getItemAt(index:int):Object
Returns the item at the specified index in the collection. | VectorCollection | ||
getItemIndex(item:Object):int
Determines which index the item appears at within the collection. | VectorCollection | ||
pop():Object
Removes the item from the end of the collection and returns it. | VectorCollection | ||
push(item:Object):void
A convenient alias for addItem(). | VectorCollection | ||
refresh():void | VectorCollection | ||
removeAll():void
Removes all items from the collection. | VectorCollection | ||
removeItem(item:Object):void
Removes a specific item from the collection. | VectorCollection | ||
removeItemAt(index:int):Object
Removes the item at the specified index from the collection and
returns it. | VectorCollection | ||
reset(collection:IListCollection):void
Replaces the collection's data with data from another collection. | VectorCollection | ||
setItemAt(item:Object, index:int):void
Replaces the item at the specified index with a new item. | VectorCollection | ||
shift():Object
Removes the first item in the collection and returns it. | VectorCollection | ||
unshift(item:Object):void
Adds an item to the beginning of the collection. | VectorCollection | ||
updateAll():void
Call updateAll() to manually inform any component
rendering the IListCollection that the properties of all,
or many, of the collection's items have changed, and that any
rendered views should be updated. | VectorCollection | ||
updateItemAt(index:int):void
Call updateItemAt() to manually inform any component
rendering the IListCollection that the properties of a
single item in the collection have changed, and that any views
associated with the item should be updated. | VectorCollection |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when an item is added to the collection. | VectorCollection | |||
Dispatched when the underlying data source changes and components will need to redraw the data. | VectorCollection | |||
Dispatched when the filterFunction property changes or the refresh() function is called on the IListCollection. | VectorCollection | |||
Dispatched when an item is removed from the collection. | VectorCollection | |||
Dispatched when an item is replaced in the collection. | VectorCollection | |||
Dispatched when the collection has changed drastically, such as when the underlying data source is replaced completely. | VectorCollection | |||
Dispatched when the sortCompareFunction property changes or the refresh() function is called on the IListCollection. | VectorCollection | |||
Dispatched when the updateAll() function is called on the ListCollection. | VectorCollection | |||
Dispatched when the updateItemAt() function is called on the ListCollection. | VectorCollection |
filterFunction | property |
filterFunction:Function
A function to determine if each item in the collection should be
included or excluded from visibility through APIs like
length
and getItemAt()
.
The function is expected to have the following signature:
function( item:Object ):Boolean
In the following example, the filter function is based on the
text of a TextInput
component:
var collection:IListCollection; //this would be created from a concrete implementation var list:List = new List(); list.dataProvider = collection; this.addChild( list ); var input:TextInput = new TextInput(); input.addEventListener( Event.CHANGE, function():void { if( input.text.length == 0 ) { collection.filterFunction = null; return; } collection.filterFunction = function( item:Object ):Boolean { var itemText:String = item.label.toLowerCase(); var filterText:String = input.text.toLowerCase(); return itemText.indexOf( filterText ) >= 0; }; } ); this.addChild( input );
public function get filterFunction():Function
public function set filterFunction(value:Function):void
length | property |
length:int
[read-only] The number of items in the collection.
public function get length():int
sortCompareFunction | property |
sortCompareFunction:Function
A function to compare each item in the collection to determine the order when sorted.
The function is expected to have the following signature:
function( a:Object, b:Object ):int
The return value should be -1
if the first item
should appear before the second item when the collection is sorted.
The return value should be 1
if the first item should
appear after the second item when the collection in sorted. Finally,
the return value should be 0
if both items have the
same sort order.
public function get sortCompareFunction():Function
public function set sortCompareFunction(value:Function):void
vectorData | property |
vectorData:Object
The Vector
data source for this collection.
Note: Ideally, this property would be typed as something other
than Object
, but there is no type that will accept all
Vector
objects without requiring a cast first.
public function get vectorData():Object
public function set vectorData(value:Object):void
VectorCollection | () | Constructor |
public function VectorCollection(data:Object = null)
Constructor
Parametersdata:Object (default = null )
|
addAll | () | method |
public function addAll(collection:IListCollection):void
Adds all items from another collection.
Parameters
collection:IListCollection |
addAllAt | () | method |
public function addAllAt(collection:IListCollection, index:int):void
Adds all items from another collection, placing the items at a specific index in this collection.
Parameters
collection:IListCollection | |
index:int |
addItem | () | method |
public function addItem(item:Object):void
Adds an item to the end of the collection.
If the collection is filtered, addItem()
may add
the item to the unfiltered data, but omit it from the filtered data.
If the item is omitted from the filtered data,
CollectionEventType.ADD_ITEM
will not be dispatched.
Parameters
item:Object |
addItemAt | () | method |
public function addItemAt(item:Object, index:int):void
Adds an item to the collection, at the specified index.
If the collection is filtered, the index is the position in the filtered data, rather than position in the unfiltered data.
Parameters
item:Object | |
index:int |
contains | () | method |
public function contains(item:Object):Boolean
Determines if the specified item is in the collection.
If the collection is filtered, contains()
will return
false
for items that are excluded by the filter.
Parameters
item:Object |
Boolean |
dispose | () | method |
public function dispose(disposeItem:Function):void
Calls a function for each item in the collection that may be used to dispose any properties on the item. For example, display objects or textures may need to be disposed.
The function is expected to have the following signature:
function( item:Object ):void
In the following example, the items in the collection are disposed:
collection.dispose( function( item:Object ):void { var accessory:DisplayObject = DisplayObject(item.accessory); accessory.dispose(); }
If the collection has a filterFunction
, it will be
removed, and it will not be restored.
Parameters
disposeItem:Function |
See also
getItemAt | () | method |
public function getItemAt(index:int):Object
Returns the item at the specified index in the collection.
Parameters
index:int |
Object |
getItemIndex | () | method |
public function getItemIndex(item:Object):int
Determines which index the item appears at within the collection. If
the item isn't in the collection, returns -1
.
If the collection is filtered, getItemIndex()
will
return -1
for items that are excluded by the filter.
Parameters
item:Object |
int |
pop | () | method |
public function pop():Object
Removes the item from the end of the collection and returns it.
ReturnsObject |
push | () | method |
public function push(item:Object):void
A convenient alias for addItem()
.
Parameters
item:Object |
See also
refresh | () | method |
public function refresh():void
removeAll | () | method |
public function removeAll():void
Removes all items from the collection.
removeItem | () | method |
public function removeItem(item:Object):void
Removes a specific item from the collection.
If the collection is filtered, removeItem()
will not
remove the item from the unfiltered data if it is not included in the
filtered data. If the item is not removed,
CollectionEventType.REMOVE_ITEM
will not be dispatched.
Parameters
item:Object |
removeItemAt | () | method |
public function removeItemAt(index:int):Object
Removes the item at the specified index from the collection and returns it.
If the collection is filtered, the index is the position in the filtered data, rather than position in the unfiltered data.
Parameters
index:int |
Object |
reset | () | method |
public function reset(collection:IListCollection):void
Replaces the collection's data with data from another collection.
Parameters
collection:IListCollection |
setItemAt | () | method |
public function setItemAt(item:Object, index:int):void
Replaces the item at the specified index with a new item.
Parameters
item:Object | |
index:int |
shift | () | method |
public function shift():Object
Removes the first item in the collection and returns it.
ReturnsObject |
unshift | () | method |
public function unshift(item:Object):void
Adds an item to the beginning of the collection.
Parameters
item:Object |
updateAll | () | method |
public function updateAll():void
Call updateAll()
to manually inform any component
rendering the IListCollection
that the properties of all,
or many, of the collection's items have changed, and that any
rendered views should be updated. The collection will dispatch the
CollectionEventType.UPDATE_ALL
event.
Alternatively, the item can dispatch an event when one of its properties has changed, and a custom item renderer can listen for that event and update itself automatically.
See also
updateItemAt | () | method |
public function updateItemAt(index:int):void
Call updateItemAt()
to manually inform any component
rendering the IListCollection
that the properties of a
single item in the collection have changed, and that any views
associated with the item should be updated. The collection will
dispatch the CollectionEventType.UPDATE_ITEM
event.
Alternatively, the item can dispatch an event when one of its properties has changed, and a custom item renderer can listen for that event and update itself automatically.
Parameters
index:int |
See also
addItem | Event |
starling.events.Event
feathers.events.CollectionEventType.ADD_ITEM
Dispatched when an item is added to the collection.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | The index of the item that has been
added. It is of type int . |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
change | Event |
starling.events.Event
starling.events.Event.CHANGE
Dispatched when the underlying data source changes and components will need to redraw the data.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | null |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
filterChange | Event |
starling.events.Event
feathers.events.CollectionEventType.FILTER_CHANGE
Dispatched when the filterFunction
property changes or the
refresh()
function is called on the IListCollection
.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | null |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
See also
removeItem | Event |
starling.events.Event
feathers.events.CollectionEventType.REMOVE_ITEM
Dispatched when an item is removed from the collection.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | The index of the item that has been
removed. It is of type int . |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
replaceItem | Event |
starling.events.Event
feathers.events.CollectionEventType.REPLACE_ITEM
Dispatched when an item is replaced in the collection.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | The index of the item that has been
replaced. It is of type int . |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
reset | Event |
starling.events.Event
feathers.events.CollectionEventType.RESET
Dispatched when the collection has changed drastically, such as when the underlying data source is replaced completely.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | null |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
sortChange | Event |
starling.events.Event
feathers.events.CollectionEventType.SORT_CHANGE
Dispatched when the sortCompareFunction
property changes or
the refresh()
function is called on the IListCollection
.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | null |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
See also
updateAll | Event |
starling.events.Event
feathers.events.CollectionEventType.UPDATE_ALL
Dispatched when the updateAll()
function is called on the
ListCollection
.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | null |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
See also
updateItem | Event |
starling.events.Event
feathers.events.CollectionEventType.UPDATE_ITEM
Dispatched when the updateItemAt()
function is called on the
ListCollection
.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
data | The index of the item that has been
updated. It is of type int . |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |
See also