How to process events chain.

Posted by theblackcascade on Stack Overflow See other posts from Stack Overflow or by theblackcascade
Published on 2011-01-10T01:10:51Z Indexed on 2011/01/10 2:53 UTC
Read the original article Hit count: 190

I need to process this chain using one LoadXML method and one urlLoader object:

ResourceLoader.Instance.LoadXML("Config.xml");
ResourceLoader.Instance.LoadXML("GraphicsSet.xml");

Loader starts loading after first frameFunc iteration (why?) I want it to start immediatly.(optional)

And it starts loading only "GraphicsSet.xml"

Loader class LoadXml method:

    public function LoadXML(URL:String):XML
    {
        urlLoader.addEventListener(Event.COMPLETE,XmlLoadCompleteListener);
        urlLoader.load(new URLRequest(URL));                
        return xml;
    }
    private function XmlLoadCompleteListener(e:Event):void
    {
        var xml:XML = new XML(e.target.data);
        trace(xml);
        trace(xml.name());
        if(xml.name() == "Config")
                XMLParser.Instance.GameSetup(xml);
        else if(xml.name() == "GraphicsSet")
                XMLParser.Instance.GraphicsPoolSetup(xml);
    }

Here is main:

        public function Main()
    {
        Mouse.hide();
        this.addChild(Game.Instance);
        this.addEventListener(Event.ENTER_FRAME,Game.Instance.Loop);            
    }

And on adding a Game.Instance to the rendering queue in game constuctor i start initialize method:

        public function Game():void
    {
        trace("Constructor");
        if(_instance)
            throw new Error("Use Instance Field");
        Initialize();           
    }

its code is:

private function Initialize():void
    {
        trace("initialization");
        ResourceLoader.Instance.LoadXML("Config.xml");
        ResourceLoader.Instance.LoadXML("GraphicsSet.xml");             
    }

Thanks.

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash