Is there a way to load library items without directly calling their linkage identifier? I am using a variable called person that is taking the click data name (jay, eric, rob) to work as my dynamic variable. Using this method works fine for loading a jpg into a container movieclip (headshot). But I cannot dynamically target a library item without writing an if statement. Is there any way for me to do this?
here is the rough sketch of where I am:
jay.addEventListener(MouseEvent.CLICK, clicked);
eric.addEventListener(MouseEvent.CLICK, clicked);
rob.addEventListener(MouseEvent.CLICK, clicked);
function clicked(e:MouseEvent):void {
var person = e.target.name;
var headLoader = new Loader();
headLoader.load(new URLRequest("images/"+person+".jpg"));
headshot.addChild(headLoader);
//This loads the proper headshot jpg from my images folder and works just fine
var bio = person+"_bio";
//trace(bio) would return "jay_bio" if jay were clicked.
var bioText = new bio(); //Here is my glitch, because bio is not technically in my library.
bios.addChild(bioText);
}
Can anyone help me with this or at least totally shut down the thought that this is possible? Thank you.