How to load classes dynamicly from xml file?

I’m trying to load classes from xml file dynamically

i have a menu class that loads different modules into it.

as i understood that getDefinitionByName function could be used, but i ran to the problem that i have to have at least one variable that is hinted to be the class that i need.

var temp:ModuleOne;
                    var mainClass:Class = Class(getDefinitionByName("com.mypage.modules.ModuleOne"));
                        var app:Object = new mainClass();
                        addChild(app as DisplayObject);

in the code var temp does the trick, so i dont get the Reference error msg #1065 Variable ModuleOne is not defined.
Does anyone have an idea how to go around this or at least how to make the hinting so that the hinting can be also loaded from the xml file and the code understoods it?