# Instantiate using XML

**URL:** <https://forum.kirupa.com/t/instantiate-using-xml/302259>\
**Category:** flash\
**Created:** [December 24, 2009, 3:02pm UTC](https://forum.kirupa.com/t/instantiate-using-xml/302259 "2009-12-24T15:02:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![renton79](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@renton79](https://forum.kirupa.com/u/renton79)\
**Post date:** [December 24, 2009, 3:02pm UTC](https://forum.kirupa.com/t/instantiate-using-xml/302259/1 "2009-12-24T15:02:00Z")

</div>

Hi

I have an XML file with stored couple of objects:

```auto

<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:

```auto

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
