/
Main.as
54 lines (43 loc) · 1.08 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
package
{
import net.flashpunk.*;
[SWF(width = "640", height = "480", backgroundColor="#000000")]
public class Main extends Engine
{
public function Main ()
{
super(640, 480, 60, true);
FP.world = new Level();
//FP.console.enable();
}
public override function init (): void
{
sitelock("draknek.org");
super.init();
}
public static function color (id:int):uint
{
if (id) {
return 0xFF0000FF;
} else {
return 0xFFFF0000;
}
}
public function sitelock (allowed:*):Boolean
{
var url:String = FP.stage.loaderInfo.url;
var startCheck:int = url.indexOf('://' ) + 3;
if (url.substr(0, startCheck) == 'file://') return true;
var domainLen:int = url.indexOf('/', startCheck) - startCheck;
var host:String = url.substr(startCheck, domainLen);
if (allowed is String) allowed = [allowed];
for each (var d:String in allowed)
{
if (host.substr(-d.length, d.length) == d) return true;
}
parent.removeChild(this);
throw new Error("Error: this game is sitelocked");
return false;
}
}
}