Using string to create class

Here’s a real head-scratcher for all you AS3 buffs out there. I have an XML file containing elements representing levels and enemies in a game I’ve been programming. I want to be able to create enemies based on information stored in their XML entries. Specifically, I want to be able to choose the class of the enemy based on a string from the XML.

However, I can’t seem to cast the string representing the enemy’s class as a class and create a new object from it. Here’s the code:


for each (var enemyInfo:XML in levelXML.level.(@num == levelNum).*) {
	var EnemyType:Class = enemyInfo.@type as Class;
	var enemy:Enemy = new EnemyType();
	enemy.x = enemyInfo.@x;
	enemy.y = enemyInfo.@y;
	addEnemy(enemy);
}

Is there any way to make this work, and if not, is there another way to get a class by its name? (something like getClassByName(“ClassName”)) Thanks much.