Hi there!
I'm trying to create a dynamicly named object.
something like
private var myVar:String = "dynamicName";
private var [myVar+"staticName"]:Object = new Object;
but what i wrote above dosn't work for some reason.
Hi there!
I'm trying to create a dynamicly named object.
something like
private var myVar:String = "dynamicName";
private var [myVar+"staticName"]:Object = new Object;
but what i wrote above dosn't work for some reason.
You could try something like this:
var myDynamicObjects:Object = new Object();
var myVar:String = "dynamicName";
myDynamicObjects[myVar + "staticName"] = new Object();
Using square brackets allows you to manipulate dynamic object properties.
== Edit ==
Better yet, like @www.Flextras.com says, use a dictionary or an array.
I'd be very surprised if you get that to work.
Better to save your dynamically created objects in an array or possibly a Dictionary. The Flex Framework uses Arrays for itemRenderers in list based classes, for example. Try something like this using a Dictionary:
private var myObjects : Dictionary = new Dictionary()
In some method where you create the children:
private var myVar:String = "dynamicName";
myObjects[myVar+"staticName"] = new Object();