- Home /
Javascript array problem...
In PC platform, there is no problems (no errors) but, when I change into android platform, 'Type 'Object' does not support slicing.' Above error is being called on almost every Array. So. I change the form 'var arr = new Array();' into 'var arr = [[["a",0],["a",0],["a",0],["a",0],["a",0],["a",0]] ........];' but, still 'Operator '<' cannot be used with a left hand side of type 'int' and a right hand side of type 'Object'.'errors in codes like 'if(arr[i][j][1] < 5) {...'. How can I solve this problem?? and Why this problem happens not in PC but in android. Please Help~~
Answer by Dreamora · Jul 28, 2011 at 07:48 AM
The javascript Array class contains objects, not int or anything else.
What you want to use are .NET inbuilt arrays ie var arr : int[] = new int[10]; for example
For example 'function Position(a1,a2,a3)' works well in PC platform mode but, in Android platform mode, Object error happens. So, I should change into 'function Position(a1 : float,a2 : float,a3 : float)' I want know reason why~similarly, in Android platform mode 'auto casting'(?!) doesn't work....
Because mobiles are always compile with #pragma strict enforced, dynamic typing is not supported. (its also not favorable performance wise even if it worked)
'var arr = [[["a", 0, Vector3(0,0,0)],["b", 0, Vector3(0,0,0)].....];'Then, there is no way to use multidimensional array in android platform mode?? like
A multidimensional array is no problem. But what you do there basically enforces an array with objects of the class Object as you happily mix different datatypes in a single array (string, int/float, Vector3) which is not possible with builtin arrays unless they are object. And by having them on object, you are back at the problem you want to solve, that they fail at the assignement because an Object is no int
$$anonymous$$ultidimensional builtin arrays exist in 2 forms, thats the int [][][] form (array of array of array - you can make this as deep or shallow as needed) as well as the int [,,] form. both have their benefits and drawbacks
Your answer
Follow this Question
Related Questions
Build error 2 Answers
Argument out of Range Exception Error - Parameter Name: Index 1 Answer
Invalid Characters in Path 1 Answer
Upgrade from 5.0.1 to 5.1.2f1, cannot build in android now, continued. 1 Answer
android building error 1 Answer