Actionscript associative array constructor? -
this seems silly ask this, there way make associative array in actionscript right in variable declarations?
e.g.
private var stages:array = [ "name" : "ny stage", "location" : "new york", "capacity" : 15000 ]
instead, way i'm doing (1): declaring array top , creating rest of array in class constructor:
private var stages:array; public function playstage(){ stages["name"] = "ny stage"; stages["location"] = "new york"; stages["capacity"] = 15000; }
can top (without creating object)?
don't use array
create associative array. if read array
documentation, recommends against practice.
use object
instead. here's link documentation on how create associative arrays:
to iterate on keys of associative array (this used length well), can use this:
var oobj:object = { "name" : "pear", "color" : "yellow" }; ... ( var key:* in oobj ) { // key or increment counter, etc. }
Comments
Post a Comment