-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.as
81 lines (60 loc) · 1.47 KB
/
Main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package
{
import flash.display.*;
import flash.events.*;
import flash.ui.*;
import flash.utils.getTimer;
import flash.utils.getDefinitionByName;
[SWF (width=640, height=480, frameRate=50)]
public class Main extends Sprite
{
private var time: int;
public static var instance: Main;
public static var screenObj: Screen;
public static var level: *;
public static var continents:Object;
public static var continentsSmall:Object;
public static var continentNames:Array;
public static function set screen (newScreenObj: Screen): void
{
if (screenObj)
{
instance.removeChild(screenObj)
}
screenObj = newScreenObj;
instance.addChild(screenObj);
instance.stage.focus = instance.stage;
}
public static function get screen (): Screen
{
return screenObj;
}
public function Main ()
{
graphics.beginFill(0x000000);
graphics.drawRect(0, 0, 640, 480);
graphics.endFill();
instance = this;
Input.attach(stage);
Preloader.init(startup);
time = getTimer();
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
var dt:int = getTimer() - time;
while (dt >= 20) {
time += 20;
dt -= 20;
if (screen) {
screen.update();
}
}
}
private function startup (): void
{
var mainClass:Class = getDefinitionByName("MainMenu") as Class;
screen = new mainClass() as Screen;
}
}
}