# Store class name in variable and create object in as3?

**URL:** https://forum.kirupa.com/t/store-class-name-in-variable-and-create-object-in-as3/242877
**Category:** Uncategorized
**Created:** [October 31, 2007, 9:02am UTC](https://forum.kirupa.com/t/store-class-name-in-variable-and-create-object-in-as3/242877 "2007-10-31T09:02:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![testmatrix](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@testmatrix](https://forum.kirupa.com/u/testmatrix)
#### Post date: [October 31, 2007, 9:02am UTC](https://forum.kirupa.com/t/store-class-name-in-variable-and-create-object-in-as3/242877/1 "2007-10-31T09:02:13Z")

</div>

I have 10 movieclip with name apple\_1\_x, apple\_2\_x…etc. I have linked those movieclips with baseclass as appleobject and class as apple\_1\_x. I have created appleobject class but not the class with movieclip names. I want them to inherit appleobject class. Now I want to generate these class names in a loop and create those objects. All movieclips are in library.

ex. var objname:String = “apple\_” + i + “\_x”; and then use main\_obj = new objname();…hope its clear what i want to do. main\_obj type is appleobject. But its showing “TypeError: Error #1007: Instantiation attempted on a non-constructor.”. I can not evalute the objname with new operator. How can i do this? any help is appriciated.
