如果我有一个数组,我可以通过设置执行以下操作键:
var example:Array = new Array();
example[20] = "500,45";
example[324] = "432,23";
如果我想要做的事的对象,我会如何实现这一目标?
我试过如下:
var example:Object = [{x:500, y:45}, {x:432, y:23}]; // Works but keys are 0 and 1
var example:Object = [20: {x:500, y:45}, 324: {x:432, y:23}]; // Compile errors
var example:Object = [20]: {x:500, y:45}, [324]: {x:432, y:23}; // Compile errors
var example:Object = [20] {x:500, y:45}, [324] {x:432, y:23}; // Compile errors
有没有达到这个好办法?
我明白我可以这样做:
var example:Object = {id20 : {x:500, y:45}, id324: {x:432, y:23} };
但它并不适合我。