Hey all, title may be abit misleading but i didnt know the correct way to write it.
Basically, how can i do the AS3 equivalent of this php code:
return array('x' => 0, 'y' => 0);
Hey all, title may be abit misleading but i didnt know the correct way to write it.
Basically, how can i do the AS3 equivalent of this php code:
return array('x' => 0, 'y' => 0);
You can do something like this
var myArray:Array = new Array({x:'0'},{y:'1'},{x:'2'});
or
var myArray:Array = new Array({x:'0',y:'1'},{a:'1',b:'2'});
private var map:Dictionary = new Dictionary();
map["x"] = 0;
map["y"] = 0;
The standard way of doing it is like this. The main thing to remember is that 'Object' in AS3 is almost equivalent to PHP's associative array's.
var obj:Object = {x:0, y:0};
trace(obj['x']); // like in PHP
trace(obj.x); // also valid
// AS3 version of foreach in PHP
for(var key:String in obj) {
trace(key +" = " + obj[key]);
}