Hi All, Just wanted to know if this is correct Code (csharp): var arr = new Array(195); arr = new Array('abc","def","ghi".....upto "195"); or I have to do it this way Code (csharp): var arr = new Array(); arr.length = 195; var abc : GameObject; var def : GameObject: all the way down to 195... arrABC[0] = "A"; arrDEF[1] = "B"; all the way to 195; Thanks, Ray
I find this to be the easiest: Code (csharp): var arr : Array = ["abc","def","ghi".....upto "195"]; Or possibly like this: Code (csharp): var arr = new Array(); arr.Push("abc"); arr.Push("def"); // etc.
Just a little tip I have found useful for things like this... Don't type the strings directly in the JavaScript file. Type them out as separate unquoted strings, one per line, and then save them in a file somewhere safe. Then, use a regular expression (under Advanced Find/Replace in Unitron) to generate the JS code from your text file. For example, if you start with abc def 195 ...etc, you can then use ^([a-z0-9]+) as your search string and "\1", as your replace string to change the strings into the right format for the JS code. If you then decide that you prefer the Array.Push(x) approach, you can just modify your regex replace string to arr.Push("\1");\n ...or whatever and do the find/replace again. A spreadsheet is a handy tool for things like this, too, because it is easy to number the lines and generate the arr[0] = "xxx" form. This technique saves a bit of typing and is "safe" because you can always generate the code again if you decide that another format would be clearer or easier to maintain, comment, etc.