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

//scpacker.gui.GTanksLoaderWindow

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.Bubble;

    public class GTanksLoaderWindow extends Sprite 
    {

        private static const bitmapFuel:Class = GTanksLoaderWindow_bitmapFuel;
        private static const fuelBitmap:BitmapData = new bitmapFuel().bitmapData;
        private static const bitmapWindow:Class = GTanksLoaderWindow_bitmapWindow;
        private static const windowBitmap:BitmapData = new bitmapWindow().bitmapData;
        private static var p:Class = GTanksLoaderWindow_p;

        private const fuelCoord:Point = new Point(30, 79);
        private const tubeR:Number = 10.5;
        private const fuelAnimPhases:Array = new Array(0.1, 0.2, 0.4, 0.6, 0.8, 0.9, 1);

        private var image:Bitmap;
        private var layer:DisplayObjectContainer;
        private var statusLabel:TextField;
        private var windowBmp:Bitmap;
        private var fuel:Shape;
        private var fuelMask:Shape;
        private var bubblesMask:Shape;
        private var tubeL:Number = 7000;
        private var showTimer:Timer;
        private var fuelAnimTimer:Timer;
        private var bubblesAnimTimer:Timer;
        private var hideTimer:Timer;
        private var showDelay:int = 0;
        private var hideDelay:int = 10000;
        private var fuelAnimDelay:int = 25;
        private var bubblesAnimDelay:int = 25;
        private var currentProcessId:Array;
        private var bubbles:Array;
        private var bubblesContainer:Sprite;
        private var lock:Boolean = false;
        private var window:TankWindow = new TankWindow(610, 305);
        private var newType:Boolean;
        private var imageLoader:GTanksLoaderImages;
        private var g:Sprite = new p();
        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;
            addChild(this.window);
            addChild(this.image);
            this.currentProcessId = new Array();
            this.bubbles = new Array();
            this.windowBmp = new Bitmap(windowBitmap);
            this.windowBmp.width = (this.windowBmp.width - 5);
            this.windowBmp.y = (this.windowBmp.y + 240);
            this.windowBmp.x = (this.windowBmp.x + 13);
            if (newType)
            {
                addChild(this.windowBmp);
            }
            else
            {
                this.window.addChild(this.g);
                this.g.x = this.image.x;
                this.g.y = ((this.image.y + this.image.height) + 10);
                this.window.height = (this.window.height - 15);
            };
            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;
            this.fuel = new Shape();
            this.fuel.graphics.beginBitmapFill(fuelBitmap);
            this.fuel.graphics.drawRect(0, 0, fuelBitmap.width, fuelBitmap.height);
            if (newType)
            {
                addChild(this.fuel);
            };
            this.fuel.x = (this.windowBmp.x + 16);
            this.fuel.y = (this.windowBmp.y + 17);
            this.fuel.width = (this.fuel.width - 5);
            this.fuelMask = new Shape();
            if (newType)
            {
                addChild(this.fuelMask);
            };
            this.fuelMask.graphics.beginFill(0, 1);
            this.fuelMask.graphics.drawRect(0, 0, 1, fuelBitmap.height);
            this.fuelMask.x = this.fuel.x;
            this.fuelMask.y = this.fuel.y;
            this.fuel.mask = this.fuelMask;
            this.bubblesContainer = new Sprite();
            if (newType)
            {
                addChild(this.bubblesContainer);
            };
            this.bubblesContainer.blendMode = BlendMode.LIGHTEN;
            this.bubblesContainer.x = this.fuel.x;
            this.bubblesContainer.y = this.fuel.y;
            var filters:Array = new Array();
            filters.push(new BlurFilter(3, 0, BitmapFilterQuality.LOW));
            this.bubblesContainer.filters = filters;
            this.bubblesMask = new Shape();
            if (newType)
            {
                addChild(this.bubblesMask);
            };
            this.bubblesMask.graphics.beginFill(0, 0xFF0000);
            this.bubblesMask.graphics.drawCircle(this.tubeR, this.tubeR, this.tubeR);
            this.bubblesMask.graphics.beginFill(0, 0xFF00);
            this.bubblesMask.graphics.drawCircle((this.tubeL - this.tubeR), this.tubeR, this.tubeR);
            this.bubblesMask.graphics.beginFill(0, 0xFF);
            this.bubblesMask.graphics.drawRect(this.tubeR, 0, (this.tubeL - (this.tubeR * 2)), (this.tubeR * 2));
            this.bubblesMask.x = this.fuel.x;
            this.bubblesMask.y = this.fuel.y;
            this.bubblesContainer.mask = this.bubblesMask;
            this.showTimer = new Timer(this.showDelay, 1);
            this.fuelAnimTimer = new Timer(this.fuelAnimDelay, this.fuelAnimPhases.length);
            this.bubblesAnimTimer = new Timer(this.bubblesAnimDelay, 1000000);
            this.hideTimer = new Timer(this.hideDelay, 1);
            this.layer.addEventListener(Event.ENTER_FRAME, this.animFuel);
            this.bubblesAnimTimer.addEventListener(TimerEvent.TIMER, this.animBubbles);
            this.bubblesAnimTimer.addEventListener(TimerEvent.TIMER_COMPLETE, this.stopBubblesAnim);
            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();
        } переделай показ картинок, но пока что только 2 картинки и сделай их чтобы брались таким образом             var cacheDirectory:File = File.applicationStorageDirectory.resolvePath("cache/resources/register");
            var file:File = cacheDirectory.resolvePath("register_background.png"); и показывались рандомно