Can I use a string variable to reference a class variable?

Posted by rson on Stack Overflow See other posts from Stack Overflow or by rson
Published on 2010-06-03T15:38:58Z Indexed on 2010/06/03 15:44 UTC
Read the original article Hit count: 195

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript-3