// Decompiled by AS3 Sorcerer 6.78
// www.buraks.com/as3sorcerer

//scpacker.gui.LoaderWindow

package scpacker.gui
{
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.geom.Point;
    import flash.display.Bitmap;
    import flash.display.DisplayObjectContainer;
    import flash.text.TextField;
    import flash.display.Shape;
    import flash.utils.Timer;
    import controls.TankWindow;
    import alternativa.init.Main;
    import flash.text.TextFormat;
    import flash.display.BlendMode;
    import flash.filters.BlurFilter;
    import flash.filters.BitmapFilterQuality;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import alternativa.tanks.model.panel.PanelModel;
    import alternativa.tanks.model.panel.IPanel;
	import scpacker.gui.dishonestprogressbar.DishonestProgressBar;

    public class GTanksLoaderWindow extends Sprite 
    {

        private const tubeR:Number = 10.5;

        private var image:Bitmap;
        private var layer:DisplayObjectContainer;
        private var statusLabel:TextField;
        private var windowBmp:Bitmap;
        private var tubeL:Number = 7000;
        private var showTimer:Timer;
        private var hideTimer:Timer;
        private var showDelay:int = 0;
        private var hideDelay:int = 10000;
		private var progressBar:DishonestProgressBar;
        private var currentProcessId:Array;
        private var lock:Boolean = false;
        private var window:TankWindow = new TankWindow(610, 305);
        private var newType:Boolean;
        private var imageLoader:GTanksLoaderImages;
        private var _prog:Number = 0;
        private var t:Number = 0;

        public function GTanksLoaderWindow(newType:Boolean=true)
        {
            this.newType = newType;
            this.layer = Main.systemUILayer;
            this.imageLoader = (Main.osgi.getService(GTanksLoaderImages) as GTanksLoaderImages);
            this.image = this.imageLoader.getRandomPict();
            this.image.x = 10;
            this.image.y = 11;
			this.window.height = (this.window.height - 15);
            addChild(this.window);
            addChild(this.image);
            this.currentProcessId = new Array();
            var tf:TextFormat = new TextFormat("Tahoma", 10, 0xFFFFFF);
            this.statusLabel = new TextField();
            this.statusLabel.text = "Status";
            this.statusLabel.defaultTextFormat = tf;
            this.statusLabel.wordWrap = true;
            this.statusLabel.multiline = true;
            this.statusLabel.y = 38;
            this.statusLabel.x = 70;
            this.statusLabel.width = 172;
            var filters:Array = new Array();
            filters.push(new BlurFilter(3, 0, BitmapFilterQuality.LOW));
            this.progressBar = new DishonestProgressBar(this.hide);
            addChild(this.progressBar);
            this.progressBar.x = (this.image.x + 1);
            this.progressBar.y = ((this.image.y + this.image.height) + 10);
            this.showTimer = new Timer(this.showDelay, 1);
            this.hideTimer = new Timer(this.hideDelay, 1);
            var t_i:Timer = new Timer((Math.random() * 7000), 1);
            t_i.addEventListener(TimerEvent.TIMER_COMPLETE, this.onChangeImage);
            t_i.reset();
            t_i.start();
            this.changeProgress(0, 0);
            this.onShowTimerComplemete(null);
            this.unlockLoaderWindow();
        }

        private function onChangeImage(t:TimerEvent):void
        {
            var time:Number;
            removeChild(this.image);
            this.image = this.imageLoader.getRandomPict();
            this.image.x = 10;
            this.image.y = 11;
            addChild(this.image);
            var tu:Timer = new Timer((((time = (Math.random() * 7000)) <= 2000) ? 7000 : time), 1);
            tu.addEventListener(TimerEvent.TIMER_COMPLETE, this.onChangeImage);
            tu.start();
        }

        public function focusIn(focusedObject:Object):void
        {
        }

        public function focusOut(exfocusedObject:Object):void
        {
        }

        public function deactivate():void
        {
            if ((!(this.lock)))
            {
                this.hideLoaderWindow();
                this.lockLoaderWindow();
            };
        }

        public function activate():void
        {
            if (this.lock)
            {
                this.unlockLoaderWindow();
            };
        }

        public function changeStatus(processId:int, value:String):void
        {
            var s:String;
            if (value.length > 100)
            {
                s = (value.slice(0, 99) + "...");
            }
            else
            {
                s = value;
            };
            this.statusLabel.text = value;
        }

        public function changeProgress(processId:int, value:Number):void
        {
            var index:int;
            if (value == 0)
            {
                this.hideTimer.stop();
                this.currentProcessId.push(processId);
                if ((((!(this.lock)) && (!(this.showTimer.running))) && (!(this.layer.contains(this)))))
                {
                    this.showTimer.reset();
                    this.showTimer.start();
                };
            }
            else
            {
                if (value == 1)
                {
                    index = this.currentProcessId.indexOf(processId);
                    if (index != -1)
                    {
                        this.currentProcessId.splice(index, 1);
                    };
                    if (this.currentProcessId.length == 0)
                    {
                        if (this.showTimer.running)
                        {
                            this.showTimer.stop();
                        }
                        else
                        {
                            if ((!(this.hideTimer.running)))
                            {
                                if ((!(this.lock)))
                                {
                                    this.hideTimer.reset();
                                    this.hideTimer.start();
                                };
                            }
                            else
                            {
                                if (this.lock)
                                {
                                    this.hideTimer.stop();
                                };
                            };
                        };
                    };
                };
            };
        }

        public function hideLoaderWindow():void
        {
            this.showTimer.stop();
            this.onHideTimerComplemete();
        }

        public function lockLoaderWindow():void
        {
            if ((!(this.lock)))
            {
                this.lock = true;
                this.showTimer.stop();
                this.hideTimer.stop();
            };
        }

        public function unlockLoaderWindow():void
        {
            if (this.lock)
            {
                this.lock = false;
            };
        }

        private function onShowTimerComplemete(e:TimerEvent):void
        {
            this.show();
        }

        private function onHideTimerComplemete(e:TimerEvent=null):void
        {
            this.hideTimer.stop();
            this.hide();
        }

        private function show():void
        {
            if ((!(this.layer.contains(this))))
            {
				this.progressBar.start();
                this.layer.addChild(this);
                Main.stage.addEventListener(Event.RESIZE, this.align);
                this.align();
            };
        }

        private function hide():void
        {
            if (this.layer.contains(this))
            {
                Main.stage.removeEventListener(Event.RESIZE, this.align);
                this.layer.removeChild(this);
            };
        }

        public function setFullAndClose(e:Event):void
        {
            this.t = (this.t + (500 / 50));
            if (((this.t <= 500) && (this.t > 0)))
            {
                this.layer.addEventListener(Event.ENTER_FRAME, this.setFullAndClose);
            }
            else
            {
                this.layer.removeEventListener(Event.ENTER_FRAME, this.setFullAndClose);
                this.hideLoaderWindow();
                PanelModel(Main.osgi.getService(IPanel)).unlock();
            };
        }

        private function align(e:Event=null):void
        {
            this.x = ((Main.stage.stageWidth - this.window.width) >>> 1);
            this.y = ((Main.stage.stageHeight - this.window.height) >>> 1);
        }

        public function addProgress(p:Number):void
        {
            this.show();
            this.t = this._prog;
            this._prog = (this._prog + p);
            this.tubeL = 7000;
        }

        public function setProgress(p:Number):void
        {
            this.show();
            this._prog = p;
            this.tubeL = 7000;
            this.t = 0;
        }

    }
}//package scpacker.gui

 как сделать когда загрузлось то полоса загрузки доходило до конца progressBar