Hi, in Flash as3 I’d commonly do something like this:
var obj:Object= {lx:32,ly:99};
print (obj.lx);
or
var obj:Object = new Object();
obj.lx = 32;
obj.ly = 99;
print (obj.lx);
And my experience and research with javascript tells me this should work in javascript as well. But in unityScript it gives me an error like
lx is not a member of ‘Object’
It seems with some experiment that unity wants this to be a Hashtable? Does the Object object not exist in Unity as it does in Javascript or As3? I can’t even get Hashtable to work as expected, get similar error.
It’s not a ‘function’ - that’s code. This is just a way of storing data.
Array is there to be used.
Not a problem.
Just remember that Unity-Script is a compiled language, while JS/AS are interpreted. From the looks of it your AS3 example uses late binding which is a no-no. Though, anonymous types are fine as I’ve demonstrated.
Oh, and I’m not a US guru so there is a small chance someone’ll pop up with a feature I’m not aware of. Just don’t hold your breath.
Well, UnityScript is not ActionScript obviously, neither it’s JavaScript. UntiyScript is actually more of a programming language, not a scripting language, so you’ll have to work with defined classes or structs.
Gues it’s time to grow up and learn programming not just scripting