1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
   | class LoadingUI extends egret.Sprite {
      private perNumber: number = 0;     private sec: number = 0;     private progressWidth: number = 0;
      public shape: egret.Shape;     private textField: egret.TextField;
      public constructor() {         super();         this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);         this.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.onRemoveToStage, this);     }
      private onAddToStage(): void {         console.log(this.stage.stageWidth);         this.textField = new egret.TextField();         this.addChild(this.textField);         this.textField.width = 480;         this.textField.height = 100;         this.textField.y = 950;         this.textField.x = this.stage.stageWidth / 2 - this.textField.width / 2;         this.textField.textAlign = "center";
          this.shape = new egret.Shape();         this.shape.width = 1600;         this.shape.height = 15;         this.shape.x = (this.stage.stageWidth - this.shape.width) / 2;         this.shape.y = 935;         this.progressWidth = this.shape.width;         this.shape.visible = false;
          let $max: egret.Matrix = new egret.Matrix(1, 0, 0, 1);         this.shape.graphics.beginGradientFill(egret.GradientType.LINEAR, [0x736BE5, 0xFF7EC8], [1, 1], [127, 255], $max);         this.shape.graphics.drawRoundRect(0, 0, this.shape.width, this.shape.height, 10, 10)         this.shape.graphics.endFill();         this.shape.alpha = 1;         this.addChild(this.shape);
      }
      public setWidth(): void {         this.shape.visible = true;         this.shape.graphics.clear();         let $max: egret.Matrix = new egret.Matrix(1, 0, 0, 1);         this.shape.graphics.beginGradientFill(egret.GradientType.LINEAR, [0x736BE5, 0xFF7EC8], [1, 1], [127, 255], $max);         this.shape.graphics.drawRoundRect(0, 0, this.shape.width, this.shape.height, 10, 10)         this.shape.graphics.endFill();     }
      private onRemoveToStage(): void {         this.removeChildren();     }
      public onProgress(current: number, total: number): void {                  if (current == 1) {             this.perNumber = total / 10;         }         this.sec = (current / this.perNumber) * 10;         let secs: any = this.sec.toFixed(0);         secs = secs / 100;         this.shape.width = this.progressWidth * secs;         this.setWidth();         this.textField.text = this.sec.toFixed(0) + " %";     } }
  |