# Dynamically creating movieclips in AS3

**URL:** <https://forum.kirupa.com/t/dynamically-creating-movieclips-in-as3/243342>\
**Category:** flash\
**Created:** [November 5, 2007, 11:43pm UTC](https://forum.kirupa.com/t/dynamically-creating-movieclips-in-as3/243342 "2007-11-05T23:43:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flextnet](https://avatars.discourse-cdn.com/v4/letter/f/7ba0ec/32.png) [@flextnet](https://forum.kirupa.com/u/flextnet)\
**Post date:** [November 5, 2007, 11:43pm UTC](https://forum.kirupa.com/t/dynamically-creating-movieclips-in-as3/243342/1 "2007-11-05T23:43:46Z")

</div>

Hi-

I’m currently making the jump from AS2 to AS3, and wondering about how to do a dynamic movieclip creation in AS3, that used to be easy in AS2.

Let’s say you are creating an mc which you’d like to create at runtime- for instance you have a bunch of different animation mc’s, and you don’t know which one you will need until runtime. In AS2, you could handle this case as follows:

var new\_mc = attachMovie(desired\_anim\_linkage, “new\_mc”, …);

where ‘desired\_anim\_linkage’ is the linkage id of the mc you want to create- this is just a string that can be built however you like, on the fly.

In AS3, we are now forced to use the ‘new’ operator to create our MC’s as far as I know:

var new\_mc = new MyAnim();

So the question is- how can we make the call to ‘new’ dynamic? In other words I’d like to do something lilke:

var myDesiredAnim = “MyAnim”;  
var new\_mc = new myDesiredAnim;

of course this won’t work, but hopefully it explains what I’m after… :goatee:

Thanks
