Create different objects based on variables

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?


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