Question: Below is a sample:

```
    private function loadLevel(name:String):void{
        level1 = new Level1(name);      
        level1.onInitialize.addOnce(onLevelReady);
        level1.loadData();              
    }

```

Loads only level1 class, now I dont want to create another function just to load another level..

I want that loadLevel to load level1,level2 etc.. on the same function.

ideas would help. :)

thanks!

Answer: 
Here's another answer:

Keep your levels in an array.

```
private const levels = [null, Level1, Level2, Level3]

```

And then:

```
private function loadLevel(name:String, n:int):void{
    level = new (levels[n])(name);      
    level.onInitialize.addOnce(onLevelReady);
    level.loadData();              
}

```
```
 private function loadLevel(name:String, level:Number):void{
     var Level:Class = getDefinitionByName("Level" + level) as Class;
     level1 = new Level(name);      
     level1.onInitialize.addOnce(onLevelReady);
     level1.loadData();              
 }

```

If your class requires a class path.

```
var Level:Class = getDefinitionByName("com.domain.Level" + level) as Class;

```