Constructs an iterator
Parameters:
Name |
Type |
Description |
list |
Array
|
Collection
|
An array or an After Effects Collection |
Properties:
Name |
Type |
Description |
list |
Array
|
Collection
|
An array or an After Effects Collection |
min |
int
|
The minimum value (inclusive) |
max |
int
|
The maximum (inclusive) |
length |
int
|
The number of items |
current |
int
|
The current item number |
atEnd |
boolean
|
true if the iterator has reached the end |
atStart |
boolean
|
true if the iterator is at the start |
valid |
boolean
|
true if the iterator is between min and max. false until next() or previous() has been called at least once |
isCollection |
boolean
|
true if the list is a Collection, false if it's a controller |
Examples
//When iterating through the whole list,
//using the function do() has the best performance
//but you can not break the loop.
//If you need it, instead of using the word 'continue',
//just make the function return.
var it = new Iterator(layers);
it.do(function doSomething(layer) {
layer.name = something;
//If we need to continue to the next item, return.
if (dontWantThis) return;
//else do something here
});
//If you need to break the loop at one time,
//like if you're searching for something,
//you can use this method instead, which is a bit less quick than using the function do()
var it = new Iterator(layers);
while (layer = it.next())
{
//do something with the layer
layer.name = something;
//when found what we're looking for
if (found) break;
}
-
-
Executes a function on each item of the List
Parameters:
Name |
Type |
Description |
callBack |
function
|
The function to execute, which takes one parameter: an item of the list |
-
-
Gets the first item,
without changing the current iterator index.
Returns:
Object
- The first item, or null if there isn't one
-
-
Sets the iterator on the index
Parameters:
Name |
Type |
Description |
index |
int
|
The index |
Returns:
Object
- The item at index, or null if there isn't
-
-
Goes to the end of the Iterator
Returns:
Object
- The item at the end, or null if length is 0
-
-
Goes to the start of the Iterator
Returns:
Object
- The item at the start, or null if length is 0
-
-
Gets the item at an index,
without changing the current iterator index.
Parameters:
Name |
Type |
Description |
index |
int
|
The index of the item |
Returns:
Object
- The item at index, or null if there isn't one
-
-
Gets the last item,
without changing the current iterator index.
Returns:
Object
- The last item, or null if there isn't one
-
-
Increments the Iterator
Must be called at least once to validate the iterator
Returns:
Object
- The next item, or null if there isn't
-
-
Decrements the Iterator
if it's called while valid is false, goes to the end
Returns:
Object
- The previous item, or null if there isn't