Instantiate using XML

Hi

I have an XML file with stored couple of objects:


<assets>
    <object>
        <mesh>Sphere(60, 12)</mesh>
    </object>
    <object>
        <mesh>Plane(400, 200, 4, 2)</mesh>
    </object>
</assets>

I can retrieve them using code below:


package {
    
    import flash.display.Sprite;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.xml.XMLDocument;
        
    public class Main extends Sprite
    {
        private var xmlFile:URLRequest = new URLRequest("imports.xml");
        private var loader:URLLoader = new URLLoader(xmlFile);
        private var array:Array = new Array();
        
        public function Main()
        {
            loader.addEventListener(Event.COMPLETE, init);
        }
        
        private function init(evt:Event):void
        {   
            var assets:XML = new XML(loader.data);
            for(var i:int=0; i < assets.mat.path.length(); i++)
            {
                array.push(assets.mat.path*);
            }
        }
            
    }
}

But when I try to use any of this stored in array objects to instantiate them it just wont work (i.e. new array[0]) or anything similar but when I put the same object name like new Sphere(60, 12), then it does work it shouldn’t be any difference as I think.

Has anyone have idea what to do to make it work???

Dave