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:

associative arrays in as3

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

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -