Well, I do not know anything about AS3, but it is much like your JavaScript code.
If it's the same thing, you can declare an object with JSON, like:
Code:
var MYCUBE = (x: 2 y: 3 z: 15, alpha: 0.5, rotationY: 62 width: 35)
It'll create an object with properties MYCUBE x, y, z, alpha, width and rotationY already declared.
If you want to add properties to an existing object, use either a function and route table "arguments", or duplicate the properties of an object ad-hoc. For example, to copy the properties of "MYCUBE" in an object "myObject", use:
Code:
for (var i in MYCUBE)
myObject [i] = MYCUBE [i]
Or via a function:
Code:
function addProp(myObject)
{
for (var i = 1; i < arguments.length; i += 2)
myObject[arguments[i]] = arguments[i+1]
}
Who used this way:
Code:
addProp(myObject, "x", 2, "y", 3, "z", 15, "alpha", 0.5, "rotationY", 62, "width", 35)
Bookmarks