# Evaluate Class name

**URL:** <https://forum.kirupa.com/t/evaluate-class-name/261122>\
**Category:** flash\
**Created:** [May 23, 2008, 10:31am UTC](https://forum.kirupa.com/t/evaluate-class-name/261122 "2008-05-23T10:31:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![markonrt8903](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/markonrt8903/32/3740_2.png) [@markonrt8903](https://forum.kirupa.com/u/markonrt8903)\
**Post date:** [May 23, 2008, 10:31am UTC](https://forum.kirupa.com/t/evaluate-class-name/261122/1 "2008-05-23T10:31:35Z")

</div>

Anyway I can do something like this:

var class\_name:String = “MyClass”; // MyClass extends MovieClip

var myObject:MovieClip = new /class\_name/(); // need to evaluate class\_name

Thanks

---

<div class="post-metadata">

**Author:** ![Rezmason](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rezmason/32/30447_2.png) [@Rezmason](https://forum.kirupa.com/u/Rezmason)\
**Post date:** [May 23, 2008, 12:31pm UTC](https://forum.kirupa.com/t/evaluate-class-name/261122/2 "2008-05-23T12:31:13Z")

</div>

Almost. Flash _can_ do this, but you don’t use String, you use [U][Class](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Class.html)[/U]:

```auto

var MyClass:Class = xyz;
var myObject:MyClass = new MyClass();

```

If you have a class name in a String, like “MovieClip”, there’s nothing you can do with it. But if you have the class’s entire definition in a String, like “flash.display.MovieClip”, you can pass it to the [U][getDefinitionByName()[/U] function to get the associated class. In reverse, if you have an Object and you want its class name, you can pass it to [U][URL=“http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getQualifiedClassName()”]getQualifiedClassName()](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getDefinitionByName())[/U].

Finally, if you’re loading a SWF file into another SWF file, and you want one of the SWFs to be able to use the classes in the other one, you can access those classes with [U][ApplicationDomain.getDefinition()](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/ApplicationDomain.html#getDefinition())[/U].

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [May 23, 2008, 1:31pm UTC](https://forum.kirupa.com/t/evaluate-class-name/261122/3 "2008-05-23T13:31:11Z")

</div>

```auto
var myButtonInstance:* = new (getDefinitionByName("myButton")) (param);

```
