Packageimpression.persistence
Classpublic class ChildElementCollection
InheritanceChildElementCollection Inheritance Object

The ChildElementCollection object is an ordered list of ChildElement objects. The ChildElementCollection class provides a way to store groups of persisted properties without resorting to cumbersome naming schemes.



Public Properties
 PropertyDefined By
  length : Number
[read-only] The number of items in the collection.
ChildElementCollection
  name : String
[read-only] The name of the collection.
ChildElementCollection
Public Methods
 MethodDefined By
  
ChildElementCollection(name:String = null)
Creates a new instance of the ChildElementCollection class.
ChildElementCollection
  
append(element:ChildElement):void
Adds an item to the end of the collection.
ChildElementCollection
  
clear():void
Removes all items from the collection.
ChildElementCollection
  
clone(deep:Boolean = true):ChildElementCollection
Returns a copy of the object.
ChildElementCollection
  
contains(element:ChildElement):Boolean
Returns a value indicating whether or not an item exists in the collection.
ChildElementCollection
  
every(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean
Executes a test function on each item in the collection until an item is reached that returns false for the specified function.
ChildElementCollection
  
filter(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):ChildElementCollection
Executes a test function on each item in the collection and constructs a new ChildElementCollection for all items that return true for the specified function.
ChildElementCollection
  
forEach(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):void
Executes a function on each item in the collection.
ChildElementCollection
  
[static] Returns a new instance of the ChildElementCollection class based on the data contained in the XML object.
ChildElementCollection
  
indexOf(element:ChildElement):Number
Returns the zero-based index of an item in the collection.
ChildElementCollection
  
insert(element:ChildElement, index:Number):void
Inserts an item at the specified zero-based index in the collection.
ChildElementCollection
  
item(index:Number):ChildElement
Returns the item located at a specific index.
ChildElementCollection
  
moveFirst(element:ChildElement):void
Moves an item to the first position in the collection (index 0).
ChildElementCollection
  
moveLast(element:ChildElement):void
Moves an item to the last position in the collection.
ChildElementCollection
  
moveNext(element:ChildElement):void
Moves an item to the position of its next sibling.
ChildElementCollection
  
Moves an item to the position of its previous sibling.
ChildElementCollection
  
moveTo(element:ChildElement, index:Number):void
Moves an item to a specific position.
ChildElementCollection
  
remove(item:*):void
Removes an item from the collection.
ChildElementCollection
  
some(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean
Executes a test function on each item in the collection until an item is reached that returns true for the specified function.
ChildElementCollection
  
sort(compareFunction:Function, sortOptions:int = 0):void
Sorts the items in the collection.
ChildElementCollection
  
toString():String
Returns the string representation of the specified object.
ChildElementCollection
  
toXML():XML
Returns an Impression-format XML object containing all the data from the object.
ChildElementCollection
Property Detail
lengthproperty
length:Number  [read-only]

The number of items in the collection. This property returns the value of the internal array's length property.


Implementation
    public function get length():Number
nameproperty 
name:String  [read-only]

The name of the collection.

The default value is children.


Implementation
    public function get name():String
Constructor Detail
ChildElementCollection()Constructor
public function ChildElementCollection(name:String = null)

Creates a new instance of the ChildElementCollection class.

If name is null, the default value will be used.

Parameters
name:String (default = null) — A String specifying the name of the collection.

See also

Method Detail
append()method
public function append(element:ChildElement):void

Adds an item to the end of the collection.

If element already exists in the collection, an error is thrown.

Parameters

element:ChildElement — The item to add to the end of the collection.


Throws
ArgumentError — element is already a member of this collection (ArgumentError).
clear()method 
public function clear():void

Removes all items from the collection.

clone()method 
public function clone(deep:Boolean = true):ChildElementCollection

Returns a copy of the object. If the deep parameter is true, a copy of each contained ChildElement object (created using the ChildElement object's clone method) is added to the copy. If the deep parameter is false, a reference to each contained ChildElement object is added to the copy.

Parameters

deep:Boolean (default = true) — Specifies how the contained ChildElement objects should be added to the copy.

Returns
ChildElementCollection — A copy of the object.

See also

contains()method 
public function contains(element:ChildElement):Boolean

Returns a value indicating whether or not an item exists in the collection.

Parameters

element:ChildElement — The item to find.

Returns
Booleantrue if the element was found in the collection and false otherwise.
every()method 
public function every(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean

Executes a test function on each item in the collection until an item is reached that returns false for the specified function. You use this method to determine whether all items in the collection meet a criterion.

For this method, the second parameter, thisObject, must be null if the first parameter, callback, is a method closure.

If the useArrayMethod parameter is true, this function returns the result of invoking the every method on the ChildElementCollection's internal Array object, using the callback and thisObject parameters. If the useArrayMethod parameter is false, this method iterates through each item in the internal Array, executing the statement

until the result of the call returns false.

If the useArrayMethod parameter is true, the callback function will be invoked with three arguments, the value of an item (a ChildElement object), the index of an item, and the Array object:

If the useArrayMethod parameter is false, the callback function will be invoked with one argument, the value of an item (a ChildElement object):

Parameters

callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
 
thisObject:* (default = null) — An object to use as this for the function.
 
useArrayMethod:Boolean (default = false) — Indicates how the callback function should be used.

Returns
Booleantrue if all items in the collection return true for the specified function; otherwise, false.

See also

Flash.Array.every()
filter()method 
public function filter(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):ChildElementCollection

Executes a test function on each item in the collection and constructs a new ChildElementCollection for all items that return true for the specified function. If an item returns false, it is not included in the new collection.

For this method, the second parameter, thisObject, must be null if the first parameter, callback, is a method closure.

If the useArrayMethod parameter is true, this function returns the result of invoking the every method on the ChildElementCollection's internal Array object, using the callback and thisObject parameters. If the useArrayMethod parameter is false, this method iterates through each item in the internal Array, executing the statement

and appending the value of _list[i] to the new collection if the function returns true.

If the useArrayMethod parameter is true, the callback function will be invoked with three arguments, the value of an item (a ChildElement object), the index of an item, and the Array object:

If the useArrayMethod parameter is false, the callback function will be invoked with one argument, the value of an item (a ChildElement object):

Parameters

callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
 
thisObject:* (default = null) — An object to use as this for the function.
 
useArrayMethod:Boolean (default = false) — Indicates how the callback function should be used.

Returns
ChildElementCollection — A new ChildElementCollection that contains all the items from the original collection that returned true. Note that the name of the return value is "[collection name] (filtered)".

See also

Flash.Array.filter()
forEach()method 
public function forEach(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):void

Executes a function on each item in the collection.

For this method, the second parameter, thisObject, must be null if the first parameter, callback, is a method closure.

If the useArrayMethod parameter is true, this function returns the result of invoking the every method on the ChildElementCollection's internal Array object, using the callback and thisObject parameters. If the useArrayMethod parameter is false, this method iterates through each item in the internal Array, executing the statement

If the useArrayMethod parameter is true, the callback function will be invoked with three arguments, the value of an item (a ChildElement object), the index of an item, and the Array object:

If the useArrayMethod parameter is false, the callback function will be invoked with one argument, the value of an item (a ChildElement object):

Parameters

callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
 
thisObject:* (default = null) — An object to use as this for the function.
 
useArrayMethod:Boolean (default = false) — Indicates how the callback function should be used.

See also

Flash.Array.forEach()
fromXML()method 
public static function fromXML(source:XML):ChildElementCollection

Returns a new instance of the ChildElementCollection class based on the data contained in the XML object.

If source is null, an empty ChildElementCollection object is returned. If the source.name property is not "cec", an error is thrown.

This method iterates through the direct children of the source XML object. If any child node's name property is "ce", a ChildElement object (created by invoking the ChildElement.fromXML class constructor with the child node) is appended to the collection. Other node names are ignored.

The XML format of a ChildElementCollection object is:

Where [child element xml] is a valid ChildElement XML property value.

Parameters

source:XML — The object containing the data to use.

Returns
ChildElementCollection — A ChildElementCollection object containing the data from the source XML object.

Throws
ArgumentError — node is not a <cec> element (ArgumentError).

See also

indexOf()method 
public function indexOf(element:ChildElement):Number

Returns the zero-based index of an item in the collection.

Parameters

element:ChildElement — The item to find.

Returns
Number — The zero-based index position of the item within the collection. If element is not found, then -1 is returned.
insert()method 
public function insert(element:ChildElement, index:Number):void

Inserts an item at the specified zero-based index in the collection.

If index is less than or equal to 0, element is inserted at the begining of the collection. If index is greater than or equal to the length property, element is appended to the end of the collection.

If element already exists in the collection, an error is thrown.

Parameters

element:ChildElement — A item to insert into the collection.
 
index:Number — The zero-based index at which insertion should occur.


Throws
ArgumentError — element is already a member of this collection (ArgumentError).
item()method 
public function item(index:Number):ChildElement

Returns the item located at a specific index. Items are stored internally in an array, so 0 is the first element. If index is less than 0 or greater than the length property, null is returned.

Parameters

index:Number — The zero-based index of the item to return.

Returns
ChildElement — A ChildElement object located at the specified index.
moveFirst()method 
public function moveFirst(element:ChildElement):void

Moves an item to the first position in the collection (index 0).

Parameters

element:ChildElement — The item to move.

See also

moveLast()method 
public function moveLast(element:ChildElement):void

Moves an item to the last position in the collection.

Parameters

element:ChildElement — The item to move.

See also

moveNext()method 
public function moveNext(element:ChildElement):void

Moves an item to the position of its next sibling.

Parameters

element:ChildElement — The item to move.

See also

movePrevious()method 
public function movePrevious(element:ChildElement):void

Moves an item to the position of its previous sibling.

Parameters

element:ChildElement — The item to move.

See also

moveTo()method 
public function moveTo(element:ChildElement, index:Number):void

Moves an item to a specific position.

If element is null, invoking this method has no effect. If element is not a member of the collection, or index is out of range, an error is thrown.

Parameters

element:ChildElement — The item to move.
 
index:Number — The position to move the item to.


Throws
ArgumentError — element is not a member of this collection (ArgumentError).
 
RangeError — index cannot be < 0 (RangeError).
 
RangeError — index cannt be > [length - 1] (RangeError).
remove()method 
public function remove(item:*):void

Removes an item from the collection.

If item is a numeric expression (Number, int, or uint), item is interpreted as the zero-based index of the item to remove. If item is a ChildElement object, item is interpreted as a reference to the item to remove.

If item is numeric, and the value is less than 0 or greater than or equal to the value of the length property, invoking this method has no effect. If item is a ChildElement object, and it is not a member of the collection, invoking this method has no effect.

Parameters

item:* — The item to remove.

some()method 
public function some(callback:Function, thisObject:* = null, useArrayMethod:Boolean = false):Boolean

Executes a test function on each item in the collection until an item is reached that returns true for the specified function. You use this method to determine whether any items in the collection meet a criterion.

For this method, the second parameter, thisObject, must be null if the first parameter, callback, is a method closure.

If the useArrayMethod parameter is true, this function returns the result of invoking the every method on the ChildElementCollection's internal Array object, using the callback and thisObject parameters. If the useArrayMethod parameter is false, this method iterates through each item in the internal Array, executing the statement

until the result of the call returns false.

If the useArrayMethod parameter is true, the callback function will be invoked with three arguments, the value of an item (a ChildElement object), the index of an item, and the Array object:

If the useArrayMethod parameter is false, the callback function will be invoked with one argument, the value of an item (a ChildElement object):

Parameters

callback:Function — The function to run on each item in the collection. This function can contain a simple comparison or a more complex operation.
 
thisObject:* (default = null) — An object to use as this for the function.
 
useArrayMethod:Boolean (default = false) — Indicates how the callback function should be used.

Returns
Booleantrue if any items in the collection return true for the specified function; otherwise, false.

See also

Flash.Array.some()
sort()method 
public function sort(compareFunction:Function, sortOptions:int = 0):void

Sorts the items in the collection. This method calls the sort method on the internal Array. Note that some of the values for the sortOptions parameter may have no effect when using this method (for example, since this method does not return a value, the Array.RETURNINDEXEDARRAY sort option has no effect).

Parameters

compareFunction:Function — A comparison function used to determine the sorting order of elements in the collection. The function should take two arguments to compare. Given the elements A and B, the result of compareFunction can have a negative, 0 or positive value:
  • A negative return value specifies that A appears before B in the sorted sequence.
  • A return value of 0 specifies that A and B have the same sort order.
  • A positive return value specifies that A appears after B in the sorted sequence.
 
sortOptions:int (default = 0) — One or more defined constants, separated by the | (bitwise OR) operation, that change the behavior of the sort from the default. This argument supports the following values:
  • 1 or Array.CASEINSENSITIVE
  • 2 or Array.DESCENDING
  • 4 or Array.UNIQUESORT
  • 8 or Array.RETURNINDEXEDARRAY
  • 16 or Array.NUMERIC

See also

flash.Array.sort();
toString()method 
public function toString():String

Returns the string representation of the specified object.

Returns
String — The string representation of the specified object.
toXML()method 
public function toXML():XML

Returns an Impression-format XML object containing all the data from the object.

Returns
XML — An XML object containing all the data from the object.

See also