package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import launcher.background.Background_Main;
    import flash.display.StageAlign;
    import flash.display.StageDisplayState;
    import flash.display.StageQuality;
    import flash.display.StageScaleMode;
    import flash.display.NativeWindow;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.display.Screen;
	import zip.ZIPResourceLoader;
	import flash.events.ProgressEvent;
	import ProgressBar;
	
	/**
	 * ...
	 * @author alekskart
	 */
	public class Main extends Sprite 
	{
		private var guiLayer:Sprite;
		public var background:Background_Main = new Background_Main();
		public var ziploader:ZIPResourceLoader = new ZIPResourceLoader();
		public var progressBar:ProgressBar = new ProgressBar(200, 10, 0xFFFFFF, 0xFF0000);
		
		public function Main() 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
			var ziploader:ZIPResourceLoader = new ZIPResourceLoader();
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			this.configureStage();
			this.createGUI();
		}
		
        private function setCenterPosition() : void
       {
            var appBounds:Rectangle = stage.nativeWindow.bounds;
            var screen:Screen = Screen.getScreensForRectangle(appBounds)[0];
            stage.stageWidth = 1024;
            stage.stageHeight = 670;
            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 = 1024;
            stage.stageHeight = 670;
            this.setCenterPosition();
        }
      
		
		private function createGUI() : void
		{
			this.guiLayer = new Sprite();
			//this.guiLayer.addChild(this.background);
			//this.addChild(this.guiLayer);
			stage.addEventListener(Event.RESIZE, onResize);
			
	// Добавить прогресс бар для отображения прогресса загрузки и распаковки
progressBar.x = stage.stageWidth / 2 - progressBar.width / 2;
progressBar.y = stage.stageHeight / 2 - progressBar.height / 2;

// Добавить прогресс-бар на сцену
addChild(progressBar);

// Добавить слушателя прогресса загрузки и распаковки
ziploader.addProgressListener(onProgressUpdate);

		}
		
private function onProgressUpdate(event:ProgressEvent):void {
    // Обновить прогресс-бар на основе прогресса загрузки и распаковки
	var progressBar:ProgressBar = getChildAt(numChildren-1) as ProgressBar;
    progressBar.setProgress(event.bytesLoaded, event.bytesTotal);
    
    // Проверить, завершена ли загрузка и распаковка
    if (event.bytesLoaded == event.bytesTotal) {
        // Удалить слушателя прогресса
        ziploader.removeProgressListener(onProgressUpdate);
        
        // Удалить прогресс-бар
        removeChild(progressBar);
    }
}
		
        private function onResize(event:Event):void
        {

        }
	}
	
} прогресс бар не двигается, вот если что его код package {
    import flash.display.Sprite;
    import flash.display.Shape;
    
    public class ProgressBar extends Sprite {
        private var _progressBarWidth:Number;
        private var _progressBarHeight:Number;
        private var _progressBarColor:uint;
        private var _backgroundBarColor:uint;
        private var _progressBar:Shape;
        private var _backgroundBar:Shape;
        
        public function ProgressBar(width:Number, height:Number, progressBarColor:uint, backgroundBarColor:uint) {
            _progressBarWidth = width;
            _progressBarHeight = height;
            _progressBarColor = progressBarColor;
            _backgroundBarColor = backgroundBarColor;
            
            createProgressBar();
            createBackgroundBar();
        }
        
        private function createProgressBar():void {
            _progressBar = new Shape();
            _progressBar.graphics.beginFill(_progressBarColor);
            _progressBar.graphics.drawRect(0, 0, 0, _progressBarHeight);
            _progressBar.graphics.endFill();
            addChild(_progressBar);
        }
        
        private function createBackgroundBar():void {
            _backgroundBar = new Shape();
            _backgroundBar.graphics.beginFill(_backgroundBarColor);
            _backgroundBar.graphics.drawRect(0, 0, _progressBarWidth, _progressBarHeight);
            _backgroundBar.graphics.endFill();
            addChild(_backgroundBar);
        }
        
        public function setProgress(currentProgress:Number, totalProgress:Number):void {
            var progress:Number = currentProgress / totalProgress;
            _progressBar.width = _progressBarWidth * progress;
        }
    }
}
ну и сама загрузка ресурсов  package zip
{
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.filesystem.File;
    import flash.filesystem.FileMode;
    import flash.filesystem.FileStream;
    import flash.net.URLRequest;
    import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequestMethod;
    import flash.net.URLLoader;
    import flash.net.URLStream;
	import flash.net.URLVariables;
    import flash.utils.ByteArray;
    import deng.fzip.FZip;
    import deng.fzip.FZipFile;
    import flash.events.ProgressEvent;
    import flash.events.EventDispatcher;

    public class ZIPResourceLoader
    {
        public var resourcesURL:String = "https://redagereborn.ru/resources.zip";
        public var versionURL:String = "https://redagereborn.ru/version.txt";
        public var localFilePath:String = File.applicationStorageDirectory.nativePath + File.separator + "resources.zip";
        public var versionFile:File = new File(File.applicationStorageDirectory.nativePath + File.separator + "version.txt");
        public var zipLoader:URLLoader = new URLLoader();
		private var downloadBytesTotal:Number = 0;
        private var downloadBytesLoaded:Number = 0;
        private var extractFilesTotal:Number = 0;
        private var extractFilesProcessed:Number = 0;
        private var progressDispatcher:EventDispatcher = new EventDispatcher();

        public function ZIPResourceLoader()
        {
            zipLoader.dataFormat = URLLoaderDataFormat.TEXT;
            zipLoader.addEventListener(Event.COMPLETE, onVersionLoaded);
            zipLoader.addEventListener(IOErrorEvent.IO_ERROR, onVersionLoadError);
            zipLoader.load(new URLRequest(versionURL));
        }

        public function onVersionLoaded(event:Event):void
        {
            var remoteVersion:Number = Number(zipLoader.data);

            var versionLoader:URLLoader = new URLLoader();
            versionLoader.dataFormat = URLLoaderDataFormat.TEXT;
            versionLoader.addEventListener(Event.COMPLETE, onLocalVersionLoaded);
            versionLoader.addEventListener(IOErrorEvent.IO_ERROR, onLocalVersionLoadError);
            versionLoader.load(new URLRequest(versionFile.nativePath));

            function onLocalVersionLoaded(event:Event):void {
                var localVersion:Number = Number(versionLoader.data);
                if (localVersion != remoteVersion) {
			        startDownloadProcess();
                } else {
                    Alert.showMessage("Local version is up to date");
                    // Пропущен код для распаковки архива
                }
            }
			
	        function onLocalVersionLoadError(event:IOErrorEvent):void {
                // Создаем новый файл version.txt и записываем в него пустую строку
                var fileStream:FileStream = new FileStream();
                fileStream.open(versionFile, FileMode.WRITE);
                fileStream.writeUTFBytes("");
                fileStream.close();
                // Запускаем процесс загрузки и распаковки архива
                startDownloadProcess();
            }
        }

        private function startDownloadProcess():void 
		{
            Alert.showMessage("Downloading resources.zip");
            var downloadStream:URLStream = new URLStream();
			downloadStream.addEventListener(ProgressEvent.PROGRESS, onDownloadProgress);
            downloadStream.addEventListener(Event.COMPLETE, onDownloadComplete);
            downloadStream.addEventListener(IOErrorEvent.IO_ERROR, onDownloadError);
            downloadStream.load(new URLRequest(resourcesURL));
        }

        private function onDownloadProgress(event:ProgressEvent):void
        {
	        downloadBytesTotal = event.bytesTotal;
	        downloadBytesLoaded = event.bytesLoaded;
	
	        // Отправить событие обновления прогресса загрузки
	        progressDispatcher.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, downloadBytesLoaded, downloadBytesTotal));
        }
		
        public function onVersionLoadError(event:IOErrorEvent):void
        {
            Alert.showMessage("Failed to load version.txt");
        }

        private function updateLocalVersion(remoteVersion:Number):void 
		{
            var fileStream:FileStream = new FileStream();
            fileStream.open(versionFile, FileMode.WRITE);
            fileStream.writeUTFBytes(remoteVersion.toString());
            fileStream.close();
        }

        public function onDownloadComplete(event:Event):void
        {
            var downloadStream:URLStream = event.target as URLStream;
            var fileBytes:ByteArray = new ByteArray();
            downloadStream.readBytes(fileBytes);

            var fileStream:FileStream = new FileStream();
            fileStream.open(new File(localFilePath), FileMode.WRITE);
            fileStream.writeBytes(fileBytes, 0, fileBytes.length);
            fileStream.close();

            //Alert.showMessage("Downloaded resources.zip");
            var remoteVersion:Number = Number(zipLoader.data); // Получаем удаленную версию файла
            updateLocalVersion(remoteVersion); // Обновляем локальную версию файла
            extractLocalArchive();
        }

        public function onDownloadError(event:IOErrorEvent):void
        {
            Alert.showMessage("Failed to download resources.zip");
        }

        public function extractLocalArchive():void
        {
            var resourcesFolder:File = new File(File.applicationStorageDirectory.nativePath + File.separator + "cache/resources");
            if (resourcesFolder.exists && resourcesFolder.isDirectory)
            {
                resourcesFolder.deleteDirectory(true); // Удаление папки “resources” с ее содержимым
            }
    
            var zipFile:FZip = new FZip();
            zipFile.addEventListener(Event.COMPLETE, onZipExtracted);
            zipFile.load(new URLRequest(localFilePath));
        }

        public function onZipExtracted(event:Event):void
        {
            var zipFile:FZip = event.target as FZip;
            zipFile.addEventListener(ProgressEvent.PROGRESS, onExtractProgress);
            try {
                for (var i:int = 0; i < zipFile.getFileCount(); i++)
                {
                    var zipEntry:FZipFile = zipFile.getFileAt(i);
                    var targetFilePath:String = File.applicationStorageDirectory.nativePath + File.separator + "cache/resources" + File.separator + zipEntry.filename;
                    var targetFile:File = new File(targetFilePath);

                    if (zipEntry.filename.charAt(zipEntry.filename.length - 1) == "/") {
                        targetFile.createDirectory();
                    } else {
                        var targetFileStream:FileStream = new FileStream();
                        targetFileStream.open(targetFile, FileMode.WRITE);
                        targetFileStream.writeBytes(zipEntry.content);
                        targetFileStream.close();
                    }
                }
                // Закрываем архив
                zipFile.close();
                // Удаляем архив
                var file:File = new File(localFilePath);
                file.deleteFile();
				
                Alert.showMessage("Extracted successfully!");
                } catch (error:Error) {
                    Alert.showMessage("Failed to extract resources.zip: " + error.message + " (" + error.errorID + ")");
                }
        }
		
private function onExtractProgress(event:ProgressEvent):void
{
	extractFilesTotal = event.bytesTotal;
	extractFilesProcessed = event.bytesLoaded;
	
	// Отправить событие обновления прогресса распаковки
	progressDispatcher.dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, extractFilesProcessed, extractFilesTotal));
}

public function addProgressListener(listener:Function):void
{
	progressDispatcher.addEventListener(ProgressEvent.PROGRESS, listener);
}

public function removeProgressListener(listener:Function):void
{
	progressDispatcher.removeEventListener(ProgressEvent.PROGRESS, listener);
}

        private function versionIsUpToDate(version:Number):Boolean
        {
            if (versionFile.exists) {
                var fileStream:FileStream = new FileStream();
                fileStream.open(versionFile, FileMode.READ);
                var localVersion:Number = Number(fileStream.readUTFBytes(fileStream.bytesAvailable));
                fileStream.close();
                return version == localVersion; // Возвращает true, если версии совпадают.
            }
            return false;
        }
    }
}