# Loading a library item dynamically

**URL:** https://forum.kirupa.com/t/loading-a-library-item-dynamically/273233
**Category:** Uncategorized
**Created:** [October 13, 2008, 1:27pm UTC](https://forum.kirupa.com/t/loading-a-library-item-dynamically/273233 "2008-10-13T13:27:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![peterl38](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@peterl38](https://forum.kirupa.com/u/peterl38)
#### Post date: [October 13, 2008, 1:27pm UTC](https://forum.kirupa.com/t/loading-a-library-item-dynamically/273233/1 "2008-10-13T13:27:10Z")

</div>

Hello,

I hope someone can help me with this as it’s sending me nuts, I realise I’m probably missing the obvious, but I have tried looking through the help in Flash and all the forums, but I’m still not getting it.

The code:

function row12\_MOUSEUP (event:MouseEvent):void  
{  
var chosenAbbr = event.currentTarget.name.toString();  
var chosenAbb:Object = MovieClip(root).abbrArray[chosenAbbr];// traces instance names ok  
trace (“from array” + chosenAbbr + " " + chosenAbb);  
var tempClip:MovieClip = new chosenAbb();  
trace (tempClip);  
tempClip.x = 0;  
tempClip.y = 0;  
MovieClip(parent).chosenAbb1.addChild (tempClip);  
}

To explain, when the mouse event occurs the current target gets a value from an array, this returns as a string which is the same as the name of the item in the library (exported for AS). This string reads out correctly for example ‘clip1’, the above code work if I replace ‘var tempClip:MovieClip = new chosenAbb();’ with ‘var tempClip:MovieClip = new clip1();’.

I need the ‘clip1’ reference to be taken from the value supplied by the array, as a String it reads correctly but the value is not used to create the child, do I need to change the whole way of working? I’ve tried all sorts but am getting nowhere fast, any help/pointers would be greatly appreciated…

Many thanks

Pete
