TypedArray
| Kind of class: | public dynamic final class |
|---|---|
| Package: | com.bourre.collection |
| Inherits from: | Proxy |
| Implements: | |
| Classpath: | com.bourre.collection.TypedArray |
| File last modified: | Monday, 24 November 2008, 11:36:49 |
Summary
- TypedArray (t:Class = null, args)
- Create a new TypedArray instance.
- push (args) : Number
- Adds one or more elements to the end of an array and returns
- unshift (args) : Number
- Adds one or more elements to the beginning of an array
- splice (startIndex:int, deleteCount:int, values) : TypedArray
- Adds elements to and removes elements from an array.
- concat (args) : TypedArray
- Concatenates the elements specified in the parameters with
- slice (startIndex:int, endIndex:int) : TypedArray
- Returns a new array that consists of a range of elements from the original array,
- filter (callback:Function, thisObject:* = null) : TypedArray
- Executes a test function on each item in the array and constructs a new array
- map (callback:Function, thisObject:* = null) : TypedArray
- Executes a function on each item in an array, and constructs a new array
- sort (args) : TypedArray
- Sorts the elements in an array.
- sortOn (fieldName:String, options:Object = null) : TypedArray
- Sorts the elements in an array according to one or more fields in the array.
- reverse : TypedArray
- Reverses the array in place.
- matchType (o:*) : Boolean
- Verify if the passed-in object can be inserted in the
- getType : Class
- Return the current type allowed in the TypedArray
- isTyped : Boolean
- Returns true if this array perform a verification
- toString : String
- Returns the String representation of the object.
- toArray : Array
- Return a copy of the internal untyped Array TypedArray
- size : uint
- Return the size of the TypedArray
- clone : TypedArray
- Clone the typed array and return a new TypedArray
- nextNameIndex (index:int) : int
- nextName (index:int) : String
- nextValue (index:int) : *
Constructor
TypedArray
TypedArray instance.Besides type the constructor works as the Arrayone, if only one additional arguments is passed to the function and
if its type is Number then this argument is used to set the length
of the TypedArray
Class instance witch is used with the is operator.- If only one
intis passed to the function
then it defines the number of elements in the array. - If several arguments is passed to the function those
values are used to fill the array.
- {VISDOC_LINK_0}
TypeError— If one or more of optionnal arguments are not of the
same type than the array one.
Instance methods
clone
TypedArray - a copy of type Array.
concat
the elements in an array and creates a new array. If the
parameters specify an array, the elements of that array are concatenated.
to be concatenated in a new array. If you don't pass any values,
the new array is a duplicate of the original array.
- An array that contains the elements from this array followed by elements from the parameters.
- {VISDOC_LINK_0}
TypeError— If one or more arguments are not of the same type that the array one.
filter
for all items that return true for the specified function. If an item returns
false, it is not included in the new array.
For this method, the second parameter, thisObject, must be null if the first
parameter, callback, is a method closure. Suppose you create a function in a
movie clip called me:
function myFunction()
{
}
Suppose you then use the filter() method on an array called myArray:
Because myFunction is a member of the Timeline class, which cannot
be overridden by me, Flash Player will throw an exception.
You can avoid this runtime error by assigning the function to
a variable, as follows:
};
myArray.filter(foo, me);
This function can contain a simple comparison
(for example, item < 20) or a more complex operation,
and is invoked with three arguments; the value of an item,
the index of an item, and the Array object:
- A new array that contains all items from the original array that returned true.
getType
TypedArray -
Classused to type checking.
isTyped
true if this array perform a verificationof the type of elements.
-
trueif this array perform a verification
of the type of elements.
map
of items corresponding to the results of the function on each item in the original array.
For this method, the second parameter, thisObject, must be null if the first parameter,
callback, is a method closure. Suppose you create a function in a movie clip called me:
function myFunction()
{
}
Suppose you then use the map() method on an array called myArray:
Because myFunction is a member of the Timeline class,
which cannot be overridden by me, Flash Player will throw
an exception. You can avoid this runtime error by assigning
the function to a variable, as follows:
};
myArray.map(foo, me);
This function can contain a simple command (such as
changing the case of an array of strings) or a more complex
operation, and is invoked with three arguments; the value
of an item, the index of an item, and the Array object:
- A new array that contains the results of the function on each item in the original array.
matchType
current
TypedArray. -
trueif the object can be inserted in
theTypedArray, eitherfalse.
nextName
- Proxy.nextName
nextNameIndex
- Proxy.nextNameIndex
nextValue
- Proxy.nextValue
push
the new length of the array.
- An integer representing the length of the new array.
- The following code creates an empty TypedArray object
letters and then populates the array with the elements
a, b, and c using the push() method.var letters:TypedArray = new TypedArray( String );
letters.push("a");
letters.push("b");
letters.push("c");
trace( letters.toString() );
- {VISDOC_LINK_0}
TypeError— If one or more arguments are not of the same type than
the array one.
reverse
- The new array
- The following code creates a TypedArray object letters with
elements a, b, and c. The order of the array elements is then reversed
using the reverse() method to produce the array [c,b,a].
var letters:TypedArray = new TypedArray( String, "a", "b", "c");
trace(letters);
letters.reverse();
trace(letters);
size
TypedArray -
uintlength of the array.
slice
without modifying the original array. The returned array includes the startIndex
element and all elements up to, but not including, the endIndex element.
If you don't pass any parameters, a duplicate of the original array is created.
If start is a negative number, the starting point begins at the end
of the array, where -1 is the last element.
If you omit this parameter, the slice includes all elements from
the starting point to the end of the array. If end is a negative
number, the ending point is specified from the end of the array,
where -1 is the last element.
- An array that consists of a range of elements from the original array.
sort
ASCII is a subset of Unicode.)
By default, Array.sort() works in the following way:
- Sorting is case-sensitive (Z precedes a).
- Sorting is ascending (a precedes b).
- The array is modified to reflect the sort order; multiple elements
that have identical sort fields are placed consecutively in the sorted
array in no particular order. - All elements, regardless of data type, are sorted as if they were strings,
so 100 precedes 99, because "1" is a lower string value than "9".
To sort an array by using settings that deviate from the default settings,
you can either use one of the sorting options described in the sortOptions
portion of the ...args parameter description, or you can create your own custom
function to do the sorting. If you create a custom function, you call the sort()
method, and use the name of your custom function as the first argument (compareFunction).
determine the behavior of the sort.
- compareFunction - A comparison function used to determine the sorting order
of elements in an array. This argument is optional. A comparison function
should take two arguments to compare. Given the elements A and B, the
result of compareFunction can have one of the following three values:- 1, if A should appear before B in the sorted sequence
- 0, if A equals B
- 1, if A should appear after B in the sorted sequence
- sortOptions - One or more numbers or defined constants, separated by the | (bitwise OR) operator, that change the behavior of the sort from the default. This argument is optional. The following values are acceptable for sortOptions:
- 1 or Array.CASEINSENSITIVE
- 2 or Array.DESCENDING
- 4 or Array.UNIQUESORT
- 8 or Array.RETURNINDEXEDARRAY
- 16 or Array.NUMERIC
- The return value depends on whether you pass any arguments,
as described in the following list:- If you specify a value of 4 or Array.UNIQUESORT for the
sortOptions argument of the ...args parameter and two or more
elements being sorted have identical sort fields, Flash returns
a value of 0 and does not modify the array. - If you specify a value of 8 or Array.RETURNINDEXEDARRAY
for the sortOptions argument of the ...args parameter,
Flash returns a sorted numeric array of the indices that reflects
the results of the sort and does not modify the array. - Otherwise, Flash returns nothing and modifies the array to reflect the sort order.
- If you specify a value of 4 or Array.UNIQUESORT for the
sortOn
The array should have the following characteristics:
- The array is an indexed array, not an associative array.
- Each element of the array holds an object with one or more properties.
- All of the objects have at least one property in common, the values
of which can be used to sort the array. Such a property is called a field.
If you pass multiple fieldName parameters, the first field represents
the primary sort field, the second represents the next sort field, and so on.
Flash sorts according to Unicode values. (ASCII is a subset of Unicode.)
If either of the elements being compared does not contain the field that
is specified in the fieldName parameter, the field is assumed to be set
to undefined, and the elements are placed consecutively in the sorted array
in no particular order.
By default, Array.sortOn() works in the following way:
- Sorting is case-sensitive (Z precedes a).
- Sorting is ascending (a precedes b).
- The array is modified to reflect the sort order;
multiple elements that have identical sort fields are
placed consecutively in the sorted array in no particular order. - Numeric fields are sorted as if they were strings, so 100 precedes 99,
because "1" is a lower string value than "9".
Flash Player 7 added the options parameter, which you can use
to override the default sort behavior. To sort a simple array
(for example, an array with only one field), or to specify a
sort order that the options parameter doesn't support, use Array.sort().
To pass multiple flags, separate them with the bitwise OR (|) operator:
Flash Player 8 added the ability to specify a different sorting option
for each field when you sort by more than one field. In Flash Player 8 and later,
the options parameter accepts an array of sort options such that each sort option
corresponds to a sort field in the fieldName parameter. The following
example sorts the primary sort field, a, using a descending sort;
the secondary sort field, b, using a numeric sort; and the tertiary sort field,
c, using a case-insensitive sort:
or an array in which the first element represents the primary
sort field, the second represents the secondary sort field, and so on.
bitwise OR (|) operator, that change the sorting behavior. The following
values are acceptable for the options parameter:
- Array.CASEINSENSITIVE or 1
- Array.DESCENDING or 2
- Array.UNIQUESORT or 4
- Array.RETURNINDEXEDARRAY or 8
- Array.NUMERIC or 16
- The return value depends on whether you pass any parameters:
- If you specify a value of 4 or Array.UNIQUESORT for the options parameter,
and two or more elements being sorted have identical sort fields, a value of 0 is
returned and the array is not modified. - If you specify a value of 8 or Array.RETURNINDEXEDARRAY for the options
parameter, an array is returned that reflects the results of the sort and the
array is not modified. - Otherwise, nothing is returned and the array is modified to reflect the sort order.
- If you specify a value of 4 or Array.UNIQUESORT for the options parameter,
splice
This method modifies the array without making a copy.
the element in the array where the insertion
or deletion begins. You can use a negative integer
to specify a position relative to the end of the array
(for example, -1 is the last element of the array).
to be deleted. This number includes the element specified
in the startIndex parameter. If you do not specify a value
for the deleteCount parameter, the method deletes all of
the values from the startIndex element to the last element
in the array. If the value is 0, no elements are deleted.
or an array, to insert into the array at the position specified
in the startIndex parameter.
- An array containing the elements that were removed from the original array.
- {VISDOC_LINK_0}
TypeError— If one or more additional arguments are not of the same type than
the array one.
toArray
TypedArray - a copy of type Array.
toString
String representation of the object. unshift
and returns the new length of the array. The other elements
in the array are moved from their original position, i, to i+1.
to be inserted at the beginning of the array.
- An integer representing the new length of the array.
- {VISDOC_LINK_0}
TypeError— If one or more arguments are not of the same type than
the array one.