Loading a library item dynamically

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