# \[as2\] variable for class name?

**URL:** <https://forum.kirupa.com/t/as2-variable-for-class-name/73388>\
**Category:** flash\
**Created:** [December 15, 2004, 9:36pm UTC](https://forum.kirupa.com/t/as2-variable-for-class-name/73388 "2004-12-15T21:36:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trace9](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@trace9](https://forum.kirupa.com/u/trace9)\
**Post date:** [December 15, 2004, 9:36pm UTC](https://forum.kirupa.com/t/as2-variable-for-class-name/73388/1 "2004-12-15T21:36:40Z")

</div>

[font=verdana, arial, helvetica][size=2]I’m trying to make an instance of a class based on a variable name, like so:

var cn:String = ‘Foo’;  
var c = new cn(); // i didn’t think this would work…

Where c would create an instance of class Foo. I’ve also tried:

var c = new eval(cn)();  
or  
var c = new eval(‘cn’)();

and then:  
var cn:String = ‘Foo()’;  
var c = new eval(cn);

I’ve done this in php, but can’t seem to get this to fly in actionscript…

Any ideas? Thanks in advance![/size][/font]
