-
Notifications
You must be signed in to change notification settings - Fork 1
/
Preloader.as
56 lines (43 loc) · 1.07 KB
/
Preloader.as
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
package
{
import flash.display.*;
public class Preloader extends Screen
{
public static function init (startup: Function): void
{
if (Main.instance.loaderInfo.bytesLoaded < Main.instance.loaderInfo.bytesTotal)
{
Main.screen = new Preloader(startup);
}
else
{
startup();
}
}
private var startup: Function;
private var progressBar: Shape;
public function Preloader (_startup: Function)
{
startup = _startup;
graphics.beginFill(0x000000);
graphics.drawRect(0, 0, 640, 480);
graphics.endFill();
graphics.beginFill(0xFFFFFF);
graphics.drawRect(68, 228, 504, 24);
graphics.endFill();
progressBar = new Shape();
addChild(progressBar);
}
public override function update (): void
{
var p:Number = (this.loaderInfo.bytesLoaded / this.loaderInfo.bytesTotal);
progressBar.graphics.beginFill(0x000000);
progressBar.graphics.drawRect(70, 230, p * 500, 20);
progressBar.graphics.endFill();
if (this.loaderInfo.bytesLoaded >= this.loaderInfo.bytesTotal)
{
startup();
}
}
}
}