-
Notifications
You must be signed in to change notification settings - Fork 0
/
Preloader.as
45 lines (39 loc) · 1.25 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
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.utils.getDefinitionByName;
import flash.display.Sprite;
public class Preloader extends Sprite
{
public function Preloader()
{
addEventListener(Event.ENTER_FRAME, progress);
// show loader
}
private function progress(e:Event):void
{
// update loader
if (stage.loaderInfo.bytesLoaded == stage.loaderInfo.bytesTotal)
{
removeEventListener(Event.ENTER_FRAME, progress);
startup();
}
this.graphics.beginFill(0, 1);
this.graphics.drawRect(100, 250, 600, 100);
this.graphics.endFill();
this.graphics.beginFill(0xffffff, 1);
this.graphics.drawRect(105, 255, 590 * stage.loaderInfo.bytesLoaded/stage.loaderInfo.bytesTotal, 90);
this.graphics.endFill();
}
private function startup():void
{
// instanciate Main class
var mainClass:Class = getDefinitionByName("net.natpat.Main") as Class;
addChild(new mainClass() as DisplayObject);
}
}
}