package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import launcher.background.Background_Main;
	import launcher.button.FightButton;
	import launcher.panel.languagePanel;
	import launcher.panel.social.socialPanel;
	import launcher.panel.buttonBar.quickPanel;
	import launcher.snow.Snow;
    import flash.display.StageAlign;
    import flash.display.StageDisplayState;
    import flash.display.StageQuality;
    import flash.display.StageScaleMode;
    import flash.display.NativeWindow;
	import flash.display.NativeWindowType;
	import flash.display.NativeWindowInitOptions;
	import flash.desktop.NativeApplication;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.display.Screen;
	import zip.ZIPResourceLoader;
	import caurina.transitions.Tweener;
	import flash.display.Loader;
    import flash.system.LoaderContext;
    import flash.system.ApplicationDomain;
    import flash.events.IOErrorEvent;
    import flash.net.URLVariables;
    import flash.net.URLRequest;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author alekskart
	 */
	public class Main extends Sprite 
	{
		public var loader:Loader;
        private var locale:String;
		private var guiLayer:Sprite;
		public var background:Background_Main = new Background_Main();
		public var progressBar:ProgressBar;
		public var socialbar:socialPanel = new socialPanel();
		public var quickbar:quickPanel = new quickPanel();
		public var fightButton:FightButton = new FightButton();
		public var bgButton:bg_button = new bg_button();
		public var languagepanel:languagePanel = new languagePanel(quickbar, fightButton);
		public var selectedLanguage:String = "RU";
		
		public function Main() 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
			//var ziploader:ZIPResourceLoader = new ZIPResourceLoader(progressBar);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			this.configureStage();
			this.createGUI();
			//это при запуске первом
            Tweener.addTween(bgButton, {alpha: 1, time: 2, transition: "easeOutCubic", onComplete: fadeOutButton});
		}
		
        private function setCenterPosition() : void
       {
            var appBounds:Rectangle = stage.nativeWindow.bounds;
            var screen:Screen = Screen.getScreensForRectangle(appBounds)[0];
            stage.stageWidth = 1034;
            stage.stageHeight = 680;
            stage.nativeWindow.maxSize = new Point(stage.nativeWindow.width,stage.nativeWindow.height);
            stage.nativeWindow.minSize = new Point(stage.nativeWindow.width,stage.nativeWindow.height);
            stage.nativeWindow.x = (screen.bounds.width - stage.nativeWindow.width) / 2;
            stage.nativeWindow.y = (screen.bounds.height - stage.nativeWindow.height) / 2;
        }
		
        private function configureStage() : void
        {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.quality = StageQuality.BEST;
            stage.displayState = StageDisplayState.NORMAL;
            stage.stageWidth = 1034;
            stage.stageHeight = 680;
            this.setCenterPosition();
        }
		
		private function createGUI() : void
		{
            this.guiLayer = new Sprite();
            this.background.width = stage.stageWidth; 
            this.background.height = stage.stageHeight; 
            this.background.y = 0;
            this.guiLayer.addChild(this.background);
            this.socialbar.x = stage.stageWidth - this.socialbar.width - 15;
            this.socialbar.y = 29; 
            this.guiLayer.addChild(this.socialbar);
			
            this.quickbar.x = (stage.stageWidth - this.quickbar.width) / 2 + 20;
            this.quickbar.y = 29;
            this.guiLayer.addChild(this.quickbar);
			
			
            this.languagepanel.x = (stage.stageWidth - this.languagepanel.width) / 2 + 20;
            this.languagepanel.y = 50;
            this.guiLayer.addChild(this.languagepanel);
			
			
            this.bgButton.x = stage.stageWidth / 2 - this.bgButton.width / 2;
            this.bgButton.y = stage.stageHeight / 2 - this.bgButton.height / 2 + 185;
            this.guiLayer.addChild(this.bgButton);
			
			
            this.fightButton.x = stage.stageWidth / 2 - this.fightButton.width / 2;
            this.fightButton.y = stage.stageHeight / 2 - this.fightButton.height / 2 + 185;
			this.fightButton.addEventListener(MouseEvent.CLICK, startPressed);
            this.guiLayer.addChild(this.fightButton);
			
			
			
            this.progressBar = new ProgressBar();
			this.progressBar.x = (stage.stageWidth - this.progressBar.width) / 2;
            this.progressBar.y = (stage.stageHeight - this.progressBar.height) / 2 + 280;
            this.guiLayer.addChild(this.progressBar);
			this.guiLayer.addChild(new Snow(25));
            addChild(this.guiLayer);
            stage.addEventListener(Event.RESIZE, onResize);
		}
		
        private function startPressed(e:MouseEvent = null):void
        {
            var options:NativeWindowInitOptions = new NativeWindowInitOptions();
            while (this.guiLayer.numChildren > 0)
            {
                this.guiLayer.removeChildAt(0);
            };
            options.renderMode = "direct";
	        options.maximizable = true;
            var window:NativeWindow = new NativeWindow(options);

            window.minSize = new Point(0x0400, 0x0300);
            window.maxSize = new Point(4095, 2880);
            window.stage.scaleMode = StageScaleMode.NO_SCALE;
            window.stage.align = StageAlign.TOP_LEFT;
    
            var loader:Loader = new Loader();
            //loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoaded);
            loader.load(new URLRequest("loader.swf"));
    
            window.stage.addChild(loader);
            window.activate();
            window.addEventListener(Event.CLOSE, onWindowClose);
            stage.nativeWindow.close(); // Закрытие предыдущего окна
       }
	   
public function updateLanguage():void {
    if (loader && loader.content && loader.content.hasOwnProperty("updateLanguage")) {
        loader.content"updateLanguage";
    }
}

     //private function onSWFLoaded(event:Event):void
     //{
     //     // Код, который вызывается после загрузки swf файла
     //       // Например, получение ссылки на загруженный контент:
     //       var loadedContent:Object = event.currentTarget.content;   
     //  }

        private function onWindowClose(event:Event):void
        {
            NativeApplication.nativeApplication.exit();
        }
		
		///Затухание
        private function fadeOutButton():void {
            Tweener.addTween(bgButton, {alpha: 0, time: 4, delay: 0, transition: "easeOutCubic", onComplete: fadeInButton});
        }
        
		//появление после затухания
        private function fadeInButton():void {
            Tweener.addTween(bgButton, {alpha: 1, time: 4, delay: 0, transition: "easeOutCubic", onComplete: fadeOutButton});
        }
		
        private function onResize(event:Event):void
        {
           var scale:Number = Math.min(stage.stageWidth / this.background.width, stage.stageHeight / this.background.height);
           this.background.width *= scale;
           this.background.height *= scale;
          var newHeight:Number = this.background.height * 0.86; 
          this.background.height = newHeight;
          this.background.x = (stage.stageWidth - this.background.width) / 2;
          // this.background.y = (stage.stageHeight - this.background.height) * 0.25; 
        }
		
		
	}
	
} смотри в loader.swf есть вот такие флаги            flashvars["locale"] = this.locale;
            flashvars["rnd"] = Math.random(); вот как сделать чтобы при смене языка locale  применялся при загрузке в loader.swf, package launcher.panel 
{
	/**
	 * ...
	 * @author alekskart
	 */
	import flash.display.MovieClip;
	import flash.text.TextField;
    import flash.text.TextFormat;
	import flash.events.MouseEvent;
	import launcher.panel.buttonBar.quickPanel;
	import flash.net.SharedObject;
	import launcher.button.FightButton;
	import flash.display.LoaderInfo;
	 
	public class languagePanel extends MovieClip 
	{
		public var ruButton:MovieClip = new MovieClip();
		public var enButton:MovieClip = new MovieClip();
		
		public var ruText:TextField = new TextField();
		public var rutextFormat:TextFormat = new TextFormat();
		//
		public  var enText:TextField = new TextField();
		public	var entextFormat:TextFormat = new TextFormat();
		//
		public var quickPanelInstance:quickPanel;
		public var fightbutton:FightButton;
		private var sharedObject:SharedObject;
        private var selectedLanguage:String; 
		
		public function languagePanel(quickPanelInstance:quickPanel, fightbutton:FightButton) 
		{
			this.quickPanelInstance = quickPanelInstance;
			this.fightbutton = fightbutton;
			ruButton.buttonMode = true;
			ruButton.addEventListener(MouseEvent.CLICK, onClickOnRU);
            addChild(ruButton);
            ruText.embedFonts = true;
            ruText.text = "RU";
            ruText.width = 90; 
            ruText.height = 30; 
			ruText.x = 20;

           
           rutextFormat.font = "MyCustomFont";
		   rutextFormat.bold = true;
		   ruText.mouseEnabled = false;
           rutextFormat.size = 16; 
           rutextFormat.color = 0xFFFFFF;
           ruText.defaultTextFormat = rutextFormat;
           ruText.setTextFormat(rutextFormat);

           ruButton.addChild(ruText);
		   
		   
			enButton.buttonMode = true;
			enButton.addEventListener(MouseEvent.CLICK, onClickOnEN);
            addChild(enButton);
            enText.embedFonts = true;
            enText.text = "EN";
            enText.width = 90; 
            enText.height = 30; 
			enText.x = ruButton.x + ruButton.width;;

           
           entextFormat.font = "MyCustomFont";
		   entextFormat.bold = true; 
		   enText.mouseEnabled = false;
           entextFormat.size = 16; 
           entextFormat.color = 0xFFFFFF; 
           enText.defaultTextFormat = entextFormat;
           enText.setTextFormat(entextFormat);

           enButton.addChild(enText);
		   
		   //сохранение положения 
		    sharedObject = SharedObject.getLocal("settings"); // создание\получение
            if (sharedObject.data.language) 
		    {
                selectedLanguage = sharedObject.data.language; // подгрузка сохраненного языка
            } 
		    else 
		    {
                selectedLanguage = "RU"; // язык поумолчанию
            }
		    quickPanelInstance.updateHeaderText(selectedLanguage);
			fightbutton.updateButton(selectedLanguage);
            updateButtonStyle(); 
		}
		
		
		public function onClickOnRU(event:MouseEvent):void 
		{
            selectedLanguage = "RU";
            updateButtonStyle();
            sharedObject.data.language = selectedLanguage;
            sharedObject.flush();
			quickPanelInstance.updateHeaderText(selectedLanguage);
		    fightbutton.updateButton(selectedLanguage);
			updateFlashVars(); // обновить параметры flashvars
        }
		
		public function onClickOnEN(event:MouseEvent):void 
		{
            selectedLanguage = "EN";
            updateButtonStyle();
            sharedObject.data.language = selectedLanguage;
            sharedObject.flush();
			quickPanelInstance.updateHeaderText(selectedLanguage);
		    fightbutton.updateButton(selectedLanguage);
			updateFlashVars(); // обновить параметры flashvars
        }	
		
private function updateFlashVars():void
{
    var flashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
    
    if (selectedLanguage == "RU")
    {
        flashVars.locale = "ru";
    }
    else if (selectedLanguage == "EN")
    {
        flashVars.locale = "en";
    }
}
		
        private function updateButtonStyle():void 
		{
            if (selectedLanguage == "RU") 
		    {
                // положение кнопки ру
                ruText.textColor = 0x00a5ec;
                enText.textColor = 0xFFFFFF;
            }
		    else 
		    {
                // положение кнопки анг
                ruText.textColor = 0xFFFFFF;
                enText.textColor = 0x00a5ec;
            }
        }
	}

}