Can I use a string variable to reference a class variable?
- by rson
Here's the scenario:
I have an external swf file with x number of movieclips in its library that I load into a containing swf. Each MC in the external swf is linked with a class name and referenced on frame 1 as such
var unique1:lineSequence1 = new lineSequence1();
the unique1 variable name will match a string variable I create in the containing swf:
function initLines():void{
lineLoader = new Loader();
lineLoader.load(new URLRequest("theLines.swf")); //load external swf
lineLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, linesLoaded);
}
function linesLoaded(e:Event):void{
var loadedswf:MovieClip = e.target.content as MovieClip;
var initialLines = projects[0].pageid; //projects is an xmllist
trace("initialLines: "+initialLines); //returns "initialLines: unique1"
lines_holder_mc.addChild(loadedswf.[initialLines]);
}
I would like to use the initialLines variable as the reference to unique1 instead of hardcoding unique1 into loadedswf.unique1 to reference said variable in the loaded swf.