Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

programmatically add property do ActionScript Object (metaprogramming)

I have an AS3 Object: {p1:"..", p2:".."} I want con create another object that contains the first one in a property whose name is defined by a variable:

var propertyName:String = "myName";
var myObj = new Object();
myObj.something_that_creates_a_property_named_as_propertyName({p1:"..", p2:".."})

does it make any sense?

like image 483
luca Avatar asked Aug 02 '09 21:08

luca


1 Answers

var propertyName:String = "myName";
var myObj = new Object();
myObj[propertyName] = {p1:"..", p2:".."};
like image 68
Michael Avatar answered Nov 04 '22 13:11

Michael