I am trying to copy what is in a Array class array into a builtin array but I keep getting a “InvalidCastException: Cannot cast from source type to destination type.” error. Here is my code.

var arr = new Array ();
//assigning numbers to arr
for(var i= 0; i < newDataParsed["data"].length; i++){
arr.Push (newDataParsed["data"]*[key4]);*

}
//testing to see what is in arr and numbers come back like they are supposed to.
for(var j = 0; j < arr.length; j++){
print(arr[j]);
}
Does anybody know what is happening here or another way to copy an Array class array into a builtin array? Any suggestions would be great. Thanks.
//And here is where the error happens
var builtinArray : int[] = array1.ToBuiltin(int);

The problem is that the type of your array “arr” is not int.

Most likely it is a string array.

So you cannot copy a string array into an int array, you need to convert it first.

you could try:

var builtinArray : int[] = new int[arr.length];

for(var i = 0; i < builtinArray.Length;i++){
builtinArray _=  parseInt(arr*);*_

}
or something similar