# Syntax for dynamically creating Custom Classes

**URL:** <https://forum.kirupa.com/t/syntax-for-dynamically-creating-custom-classes/240592>\
**Category:** flash\
**Created:** [October 4, 2007, 8:58am UTC](https://forum.kirupa.com/t/syntax-for-dynamically-creating-custom-classes/240592 "2007-10-04T08:58:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![schmichael](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@schmichael](https://forum.kirupa.com/u/schmichael)\
**Post date:** [October 4, 2007, 8:58am UTC](https://forum.kirupa.com/t/syntax-for-dynamically-creating-custom-classes/240592/1 "2007-10-04T08:58:11Z")

</div>

Hi there, I am trying to load 4 custom classes from my library that are movieclip symbols and I want to be able to do this dynamically without having to hard-code each instance.

At the moment I am writing the code like this:

[AS]  
var my1:S1 = new S1();  
var my2:S2 = new S2();  
var my3:S3 = new S3();  
var my4:S4 = new S4();

function addMys() {  
for (var i=0; i\<4; i++) {  
var myS:Sprite = this[“my”+(i+1)]   
this.addChild(myS);   
}  
}  
[/AS]

I would like to create the instances of the sprites within my loop but I’m not sure of the syntax, if someone could show me how to write this I would be really grateful.  
Thanks!

Schm
