6

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?

2
  • This is not really metaprogramming. I do not know the exact word, but it is posible because actionscript is a dynamic language. Commented Aug 3, 2009 at 8:17
  • you're right.. I never really understood what metaprogramming was, I'll read some more about it! Commented Aug 4, 2009 at 19:42

1 Answer 1

15
var propertyName:String = "myName";
var myObj = new Object();
myObj[propertyName] = {p1:"..", p2:".."};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.