Packagefeathers.data
Classpublic class ListCollection
InheritanceListCollection Inheritance starling.events.EventDispatcher

Wraps a data source with a common API for use with UI controls, like lists, that support one dimensional collections of data. Supports custom "data descriptors" so that unexpected data sources may be used. Supports Arrays, Vectors, and XMLLists automatically.

See also

ArrayListCollectionDataDescriptor
VectorListCollectionDataDescriptor
XMLListListCollectionDataDescriptor


Public Properties
 PropertyDefined By
  data : Object
The data source for this collection.
ListCollection
  dataDescriptor : IListCollectionDataDescriptor
Describes the underlying data source by translating APIs.
ListCollection
  length : int
[read-only] The number of items in the collection.
ListCollection
Public Methods
 MethodDefined By
  
ListCollection(data:Object = null)
Constructor
ListCollection
  
addAll(collection:ListCollection):void
Adds all items from another collection.
ListCollection
  
addAllAt(collection:ListCollection, index:int):void
Adds all items from another collection, placing the items at a specific index in this collection.
ListCollection
  
addItem(item:Object):void
Adds an item to the end of the collection.
ListCollection
  
addItemAt(item:Object, index:int):void
Adds an item to the collection, at the specified index.
ListCollection
  
contains(item:Object):Boolean
Determines if the specified item is in the collection.
ListCollection
  
dispose(disposeItem:Function):void
Calls a function for each item in the collection that may be used to dispose any properties on the item.
ListCollection
  
getItemAt(index:int):Object
Returns the item at the specified index in the collection.
ListCollection
  
getItemIndex(item:Object):int
Determines which index the item appears at within the collection.
ListCollection
  
pop():Object
Removes the item from the end of the collection and returns it.
ListCollection
  
push(item:Object):void
Adds an item to the end of the collection.
ListCollection
  
removeAll():void
Removes all items from the collection.
ListCollection
  
removeItem(item:Object):void
Removes a specific item from the collection.
ListCollection
  
removeItemAt(index:int):Object
Removes the item at the specified index from the collection and returns it.
ListCollection
  
setItemAt(item:Object, index:int):void
Replaces the item at the specified index with a new item.
ListCollection
  
shift():Object
Removed the item from the beginning of the collection and returns it.
ListCollection
  
unshift(item:Object):void
Adds an item to the beginning of the collection.
ListCollection
  
updateItemAt(index:int):void
If an item doesn't dispatch an event or signal to indicate that it has changed, you can manually tell the collection about the change, and the collection will dispatch the CollectionEventType.UPDATE_ITEM event to manually notify the component that renders the data.
ListCollection
Events
 Event Summary Defined By
  Dispatched when an item is added to the collection.ListCollection
  Dispatched when the underlying data source changes and the ui will need to redraw the data.ListCollection
  Dispatched when an item is removed from the collection.ListCollection
  Dispatched when an item is replaced in the collection.ListCollection
  Dispatched when the collection has changed drastically, such as when the underlying data source is replaced completely.ListCollection
  Dispatched when a property of an item in the collection has changed and the item doesn't have its own change event or signal.ListCollection
Property Detail
dataproperty
data:Object

The data source for this collection. May be any type of data, but a dataDescriptor needs to be provided to translate from the data source's APIs to something that can be understood by ListCollection.

Data sources of type Array, Vector, and XMLList are automatically detected, and no dataDescriptor needs to be set if the ListCollection uses one of these types.


Implementation
    public function get data():Object
    public function set data(value:Object):void
dataDescriptorproperty 
dataDescriptor:IListCollectionDataDescriptor

Describes the underlying data source by translating APIs.


Implementation
    public function get dataDescriptor():IListCollectionDataDescriptor
    public function set dataDescriptor(value:IListCollectionDataDescriptor):void

See also

lengthproperty 
length:int  [read-only]

The number of items in the collection.


Implementation
    public function get length():int
Constructor Detail
ListCollection()Constructor
public function ListCollection(data:Object = null)

Constructor

Parameters
data:Object (default = null)
Method Detail
addAll()method
public function addAll(collection:ListCollection):void

Adds all items from another collection.

Parameters

collection:ListCollection

addAllAt()method 
public function addAllAt(collection:ListCollection, index:int):void

Adds all items from another collection, placing the items at a specific index in this collection.

Parameters

collection:ListCollection
 
index:int

addItem()method 
public function addItem(item:Object):void

Adds an item to the end of the collection.

Parameters

item:Object

addItemAt()method 
public function addItemAt(item:Object, index:int):void

Adds an item to the collection, at the specified index.

Parameters

item:Object
 
index:int

contains()method 
public function contains(item:Object):Boolean

Determines if the specified item is in the collection.

Parameters

item:Object

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

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

Returns
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.

Parameters

item:Object

Returns
int
pop()method 
public function pop():Object

Removes the item from the end of the collection and returns it.

Returns
Object
push()method 
public function push(item:Object):void

Adds an item to the end of the collection.

Parameters

item:Object

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.

Parameters

item:Object

removeItemAt()method 
public function removeItemAt(index:int):Object

Removes the item at the specified index from the collection and returns it.

Parameters

index:int

Returns
Object
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

Removed the item from the beginning of the collection and returns it.

Returns
Object
unshift()method 
public function unshift(item:Object):void

Adds an item to the beginning of the collection.

Parameters

item:Object

updateItemAt()method 
public function updateItemAt(index:int):void

If an item doesn't dispatch an event or signal to indicate that it has changed, you can manually tell the collection about the change, and the collection will dispatch the CollectionEventType.UPDATE_ITEM event to manually notify the component that renders the data.

Parameters

index:int

Event Detail
addItem Event
Event Object Type: starling.events.Event
Event.type property = feathers.events.CollectionEventType.ADD_ITEM

Dispatched when an item is added to the collection.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
currentTargetThe 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.
dataThe index of the item that has been added. It is of type int.
targetThe 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.

Dispatched when an item is added to the collection.
change Event  
Event Object Type: starling.events.Event
Event.type property = starling.events.Event.CHANGE

Dispatched when the underlying data source changes and the ui will need to redraw the data.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
currentTargetThe 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.
datanull
targetThe 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.

removeItem Event  
Event Object Type: starling.events.Event
Event.type property = feathers.events.CollectionEventType.REMOVE_ITEM

Dispatched when an item is removed from the collection.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
currentTargetThe 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.
dataThe index of the item that has been removed. It is of type int.
targetThe 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.

Dispatched when an item is removed from the collection.
replaceItem Event  
Event Object Type: starling.events.Event
Event.type property = feathers.events.CollectionEventType.REPLACE_ITEM

Dispatched when an item is replaced in the collection.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
currentTargetThe 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.
dataThe index of the item that has been replaced. It is of type int.
targetThe 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.

Dispatched when an item is replaced in the collection with a different item.
reset Event  
Event Object Type: starling.events.Event
Event.type property = 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:

PropertyValue
bubblesfalse
currentTargetThe 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.
datanull
targetThe 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.

Dispatched when the data provider's source is completely replaced.
updateItem Event  
Event Object Type: starling.events.Event
Event.type property = feathers.events.CollectionEventType.UPDATE_ITEM

Dispatched when a property of an item in the collection has changed and the item doesn't have its own change event or signal. This event is only dispatched when the updateItemAt() function is called on the ListCollection.

In general, it's better for the items themselves to dispatch events or signals when their properties change.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
currentTargetThe 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.
dataThe index of the item that has been updated. It is of type int.
targetThe 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.

Dispatched when an item in the collection has changed.