View comments | RSS feed

List class

Inheritance MovieClip > UIObject class > UIComponent class > View > ScrollView > ScrollSelectList > List

ActionScript Class Name mx.controls.List

The List component is composed of three parts: items, rows, and a data provider.

An item is an ActionScript object used for storing the units of information in the list. A list can be thought of as an array; each indexed space of the array is an item. An item is an object that typically has a label property that is displayed and a data property that is used for storing data.

A row is a component that is used to display an item. Rows are either supplied by default by the list (the SelectableRow class is used), or you can supply them, usually as a subclass of the SelectableRow class. The SelectableRow class implements the CellRenderer API, which is the set of properties and methods that allow the list to manipulate each row and send data and state information (for example, size, selected, and so on) to the row for display.

A data provider is a data model of the list of items in a list. Any array in the same frame as a list is automatically given methods that let you manipulate data and broadcast changes to multiple views. You can build an Array instance or get one from a server and use it as a data model for multiple lists, combo boxes, data grids, and so on. The List component has methods that proxy to its data provider (for example, addItem() and removeItem()). If no external data provider is provided to the list, these methods create a data provider instance automatically, which is exposed through List.dataProvider.

To add a List component to the tab order of an application, set its tabIndex property (see UIComponent.tabIndex). The List component uses the Focus Manager to override the default Flash Player focus rectangle and draw a custom focus rectangle with rounded corners. For more information, see Creating custom focus navigation in Using Components.

Each component class has a version property, which is a class property. Class properties are available only on the class itself. The version property returns a string that indicates the version of the component. To access this property, use the following code:

trace(mx.controls.List.version);

NOTE

 

The code trace(myListInstance.version); returns undefined.

Method summary for the List class

The following table lists methods of the List class.

Method

Description

List.addItem()

Adds an item to the end of the list.

List.addItemAt()

Adds an item to the list at the specified index.

List.getItemAt()

Returns the item at the specified index.

List.removeAll()

Removes all items from the list.

List.removeItemAt()

Removes the item at the specified index.

List.replaceItemAt()

Replaces the item at the specified index with another item.

List.setPropertiesAt()

Applies the specified properties to the specified item.

List.sortItems()

Sorts the items in the list according to the specified compare function.

List.sortItemsBy()

Sorts the items in the list according to a specified property.

Methods inherited from the UIObject class

The following table lists the methods the List class inherits from the UIObject class. When calling these methods, use the form listInstance.methodName.

Method

Description

UIObject.createClassObject()

Creates an object on the specified class.

UIObject.createObject()

Creates a subobject on an object.

UIObject.destroyObject()

Destroys a component instance.

UIObject.doLater()

Calls a function when parameters have been set in the Property and Component inspectors.

UIObject.getStyle()

Gets the style property from the style declaration or object.

UIObject.invalidate()

Marks the object so it is redrawn on the next frame interval.

UIObject.move()

Moves the object to the requested position.

UIObject.redraw()

Forces validation of the object so it is drawn in the current frame.

UIObject.setSize()

Resizes the object to the requested size.

UIObject.setSkin()

Sets a skin in the object.

UIObject.setStyle()

Sets the style property on the style declaration or object.

Methods inherited from the UIComponent class

The following table lists the methods the List class inherits from the UIComponent class. When calling these methods, use the form listInstance.methodName.

Method

Description

UIComponent.getFocus()

Returns a reference to the object that has focus.

UIComponent.setFocus()

Sets focus to the component instance.

Property summary for the List class

The following table lists properties of the List class.

Property

Description

List.cellRenderer

Assigns the class or symbol to use to display each row of the list.

List.dataProvider

The source of the list items.

List.hPosition

The horizontal position of the list.

List.hScrollPolicy

Indicates whether the horizontal scroll bar is displayed ("on") or not ("off").

List.iconField

A field in each item to be used to specify icons.

List.iconFunction

A function that determines which icon to use.

List.labelField

Specifies a field of each item to be used as label text.

List.labelFunction

A function that determines which fields of each item to use for the label text.

List.length

The number of items in the list. This property is read-only.

List.maxHPosition

The number of pixels the list can scroll to the right, when List.hScrollPolicy is set to "on".

List.multipleSelection

Indicates whether multiple selection is allowed in the list (true) or not (false).

List.rowCount

The number of rows that are at least partially visible in the list.

List.rowHeight

The pixel height of every row in the list.

List.selectable

Indicates whether the list is selectable (true) or not (false).

List.selectedIndex

The index of a selection in a single-selection list.

List.selectedIndices

An array of the selected items in a multiple-selection list.

List.selectedItem

The selected item in a single-selection list. This property is read-only.

List.selectedItems

The selected item objects in a multiple-selection list. This property is read-only.

List.vPosition

The topmost visible item of the list.

List.vScrollPolicy

Indicates whether the vertical scroll bar is displayed ("on"), not displayed ("off"), or displayed when needed ("auto").

Properties inherited from the UIObject class

The following table lists the properties the List class inherits from the UIObject class. When accessing these properties, use the form listInstance.propertyName.

Property

Description

UIObject.bottom

The position of the bottom edge of the object, relative to the bottom edge of its parent. Read-only.

UIObject.height

The height of the object, in pixels. Read-only.

UIObject.left

The left edge of the object, in pixels. Read-only.

UIObject.right

The position of the right edge of the object, relative to the right edge of its parent. Read-only.

UIObject.scaleX

A number indicating the scaling factor in the x direction of the object, relative to its parent.

UIObject.scaleY

A number indicating the scaling factor in the y direction of the object, relative to its parent.

UIObject.top

The position of the top edge of the object, relative to its parent. Read-only.

UIObject.visible

A Boolean value indicating whether the object is visible (true) or not (false).

UIObject.width

The width of the object, in pixels. Read-only.

UIObject.x

The left edge of the object, in pixels. Read-only.

UIObject.y

The top edge of the object, in pixels. Read-only.

Properties inherited from the UIComponent class

The following table lists the properties the List class inherits from the UIComponent class. When accessing these properties, use the form listInstance.propertyName.

Property

Description

UIComponent.enabled

Indicates whether the component can receive focus and input.

UIComponent.tabIndex

A number indicating the tab order for a component in a document.

Event summary for the List class

The following table lists events that of the List class.

Event

Description

List.change

Broadcast whenever user interaction causes the selection to change.

List.itemRollOut

Broadcast when the pointer rolls over and then off of list items.

List.itemRollOver

Broadcast when the pointer rolls over list items.

List.scroll

Broadcast when a list is scrolled.

Events inherited from the UIObject class

The following table lists the events the List class inherits from the UIObject class.

Event

Description

UIObject.draw

Broadcast when an object is about to draw its graphics.

UIObject.hide

Broadcast when an object's state changes from visible to invisible.

UIObject.load

Broadcast when subobjects are being created.

UIObject.move

Broadcast when the object has moved.

UIObject.resize

Broadcast when an object has been resized.

UIObject.reveal

Broadcast when an object's state changes from invisible to visible.

UIObject.unload

Broadcast when the subobjects are being unloaded.

Events inherited from the UIComponent class

The following table lists the events the List class inherits from the UIComponent class.

Event

Description

UIComponent.focusIn

Broadcast when an object receives focus.

UIComponent.focusOut

Broadcast when an object loses focus.

UIComponent.keyDown

Broadcast when a key is pressed.

UIComponent.keyUp

Broadcast when a key is released.


Version 8

Comments


mbd said on Oct 19, 2005 at 3:09 PM :
The property tabIndex always returns undefined and cannot be set.

In case anyone was looking into this.

This is true for List, Tree, and DataGrid (only ones I've found so far).
djtechwriter said on Oct 20, 2005 at 10:39 AM :
mbd,

You're correct. List, Tree, and DataGrid seem to ignore the tabIndex setting. A bug has been filed.
DougStudioUK said on Jan 25, 2006 at 8:09 AM :
I managed to work around this by using the Arrange>Bring To Front option (found when right clicking on each component) for each component in the order i needed it to tab....seems to work fine.
cfpb said on Feb 26, 2007 at 11:37 AM :
How does one assign a value to the combobox in flash at the time of binding (or alternatively after binding). For example, a state list combobox that displays text of "Alaska", but sends a value of "AK"?

I can ge the list to bind via webserviceconnector.trigger(), however the value returned is null (empty). Any help would be great thanks!
No screen name said on May 17, 2007 at 4:11 AM :
How does one change the default color for the item selected in the list?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00003703.html