package com.afi.autoquote.commands
{
    import com.afi.autoquote.config.Config;
    import com.afi.autoquote.model.Model;
    import com.afi.autoquote.model.parsers.CopyDeckParser;
    
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;

    public class LoadCopyDeck
        extends Command
    {
        public function execute():void {
            logExecute();
            
            var l:URLLoader = new URLLoader();
                l.addEventListener(Event.COMPLETE, function(e:Event):void {
                    // Parse the xml and store in model
                    CopyDeckParser.parse(new XML(e.currentTarget.data), Model.instance.text);
                })
                l.load(new URLRequest(Config.instance.paths.copyDeck));
        }
    }
}