# Dynamically load a library mc using a string?

**URL:** <https://forum.kirupa.com/t/dynamically-load-a-library-mc-using-a-string/282449>\
**Category:** flash\
**Created:** [February 22, 2009, 10:42am UTC](https://forum.kirupa.com/t/dynamically-load-a-library-mc-using-a-string/282449 "2009-02-22T10:42:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjalmarsn](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hjalmarsn](https://forum.kirupa.com/u/hjalmarsn)\
**Post date:** [February 22, 2009, 10:42am UTC](https://forum.kirupa.com/t/dynamically-load-a-library-mc-using-a-string/282449/1 "2009-02-22T10:42:23Z")

</div>

Hi! I want to load one out of 18 different instances from my library (exported as mc1-mc18). In AS2 this was simple! I fetched the variable (whC) that contained the name of the movieclip to be loaded and just put it into attachMovie

AS2:

```auto
_loc.attachMovie(whC,"clip"+k,this.getNextHighestDepth());

```

In AS3 do I have to use this long if/else statement to make it work the same? ☹

```auto
public function fetchTile(whC:String):MovieClip {
            if (whC=="mc1") {
                fetched= new mc1();
            } else if (whC=="mc2") {
                fetched = new mc2();
            } else if (whC=="mc3") {
                fetched = new mc3();
            } else if (whC=="mc4") {
                fetched = new mc4();
            } else if (whC=="mc6") {
                fetched = new mc6();
            } else if (whC=="mc7") {
                fetched = new mc7();
            } else if (whC=="mc8") {
                fetched = new mc8();
            } else if (whC=="mc9") {
                fetched = new mc9();
            } else if (whC=="mc10") {
                fetched = new mc10();
            } else if (whC=="mc11") {
                fetched = new mc11();
            } else if (whC=="mc12") {
                fetched = new mc12();
            } else if (whC=="mc13") {
                fetched = new mc13();
            } else if (whC=="mc14") {
                fetched = new mc14();
            } else if (whC=="mc15") {
                fetched = new mc15();
            } else if (whC=="mc16") {
                fetched = new mc16();
            } else if (whC=="mc17") {
                fetched= new mc17();
            } else {
                fetched = new mc18();
            }
            return fetched;
        }

```
