forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaddItemsAt.as
More file actions
32 lines (26 loc) · 885 Bytes
/
addItemsAt.as
File metadata and controls
32 lines (26 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package utils.array
{
/**
Modifies original Array by adding all the elements from another Array at a specified position.
@param tarArray: Array to add elements to.
@param items: Array of elements to add.
@param index: Position where the elements should be added.
@return Returns <code>true</code> if the Array was changed as a result of the call; otherwise <code>false</code>.
@example
<listing version="3.0">
var alphabet:Array = new Array("a", "d", "e");
var parts:Array = new Array("b", "c");
ArrayUtil.addItemsAt(alphabet, parts, 1);
trace(alphabet);
</listing>
*/
public function addItemsAt(tarArray:Array, items:Array, index:int = 0x7FFFFFFF):Boolean
{
if (items.length == 0)
return false;
var args:Array = items.concat();
args.splice(0, 0, index, 0);
tarArray.splice.apply(null, args);
return true;
}
}