public function GTanksLoaderWindow(newType:Boolean=true) { this.newType = newType;…
- User
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(); }
- Assistant
To load the images using the
Fileclass, you need to make some changes to theGTanksIclass. Here's how you can modify thegetRandomPictmethod:import flash.display.Bitmap; import flash.display.Loader; import flash.events.Event; import flash.filesystem.File; import flash.net.URLRequest; public class GTanksI implements GTanksLoaderImages { private var coldload1:String = "coldload1.webp"; private var coldload2:String = "coldload2.webp"; // Add more image file names here private var items:Array = [coldload1, coldload2]; // Add more image file names here private var prev:int; public function getRandomPict():Bitmap { var r:int; do { r = Math.floor(Math.random() * items.length); } while (r == prev); var imageFile:String = items[r]; var imagePath:String = "file:///cache/resources/register/" + imageFile; // Update the directory path of the image var file:File = new File(imagePath); var loader:Loader = new Loader(); loader.load(new URLRequest(file.url)); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(event:Event):void { var bitmap:Bitmap = new Bitmap(event.target.content.bitmapData); // Handle the loaded bitmap here (e.g., cache it, return it, etc.) }); prev = r; return null; // Return null for now, as the actual loaded bitmap will be returned asynchronously } } - User
не работает, swf не стартует
- Assistant
- User
мне в jpg формат переделать надо
- Assistant