This is a pretty straight forward query. I have a bunch of MovieClips in the library, set to export for ActionScript as follows:
Overlay_1
Overlay_2
Overlay_3
...
...
...
There may be more and their names might be anything (for example, not numerically ascending).
Currently, to add one of these MovieClips to the stage I would use the following Script:
var overlay_1:Overlay_1 = new Overlay_1();
addChild(overlay_1);
The problem with this I want to set a variable with a string, let's say "Overlay_6" and then add the MovieClip from the library that has that Export name to the stage.
For example:
var overlayToAdd:String = "Overlay_6";
var overlayCotent:this[overlayToAdd] = new this[overlayToAdd+"()"];
addChild(overlayCotent);
The end result being that what ever string I set the variable 'overlayToAdd' to is what gets picked out of the library and added to the stage.
If someone could help id be aver so grateful! I'll then be free to set the 'overlayToAdd' variable to values from arrays or however I want!
In the old days (AS2), I would have just used an eval function but that's gone now.