1

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.

1 Answer 1

1

You can just remove the dot and use bracket notation like this:

lines_holder_mc.addChild(loadedswf[initialLines]);
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.