# Create different objects based on variables

**URL:** <https://forum.kirupa.com/t/create-different-objects-based-on-variables/331354>\
**Category:** Uncategorized\
**Created:** [July 13, 2013, 1:02am UTC](https://forum.kirupa.com/t/create-different-objects-based-on-variables/331354 "2013-07-13T01:02:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenneth\_lkf](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@kenneth\_lkf](https://forum.kirupa.com/u/kenneth_lkf)\
**Post date:** [July 13, 2013, 1:02am UTC](https://forum.kirupa.com/t/create-different-objects-based-on-variables/331354/1 "2013-07-13T01:02:46Z")

</div>

Hi everyone,

I’m new to as3 and would like to seek you help on the following question. I’ve been searching on the web but couldn’t find the solution… Here’s the thing:

I named a list of movieclip from e1 to e8 and i want to create different objects based on variables stored in tet[en][1]. I’ve tried “enm = new this[“e” + tet[en][1]]” but this couldn’t work, is there anyway to do this more efficiently as I have more movieclips to add?

```auto

var enm:MovieClip;
if (tet[en][1] == 1) {enm = new e1();}
if (tet[en][1] == 2) {enm = new e2();}
if (tet[en][1] == 3) {enm = new e3();}
if (tet[en][1] == 4) {enm = new e4();}
if (tet[en][1] == 5) {enm = new e5();}
if (tet[en][1] == 6) {enm = new e6();}
if (tet[en][1] == 7) {enm = new e7();}
if (tet[en][1] == 8) {enm = new e8();}

```

Thanks
