forked from benlowry/openfl-fglads-preloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFGLPreloader.hx
84 lines (72 loc) · 2.75 KB
/
FGLPreloader.hx
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
82
83
84
package ;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.Lib;
import openfl.Assets;
@:bitmap("../assets/images/adbackground.jpg") class AdBG extends BitmapData { }
class FGLPreloader extends NMEPreloader
{
private var wrapper:FGLWrapper;
public function new()
{
super();
addEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(Event.REMOVED_FROM_STAGE, dispose);
}
private function init(e:Event)
{
removeEventListener(Event.ADDED_TO_STAGE, init);
wrapper = new FGLWrapper(
{
adid: "FGL-20027885",
gametitle: Settings.NAME + " Jigsaw Puzzles",
developer: "PuzzleBoss", // your name
developerlink: "http://puzzleboss.com/?from=" + Settings.PACKAGE, // your url
onerror: adFinished, // function(e:Event)
oncomplete: adFinished, // function(e:Event)
custombackground: new Bitmap(new AdBG(0, 0)) // optional displayobject to use as background
/*
sponsor: "", // sponsor's name
sponsorlink: "", // sponsor's url
background: 0x1C3755, // optional background color
titletext: 0xFFFFFF, // color for the game name
titlebackground: 0x000000, // background color underlaying the game name
fgltext: 0xFFFFFF, // color for the 'ads by fgl'
fglbackground: 0x000000, // background color underlaying 'ads by fgl'
preloadertext: 0x999999, // preloader text color
preloaderbar: 0x253240, // preloader progress bar color
preloaderbackground: 0x000000, // preloader bar background color
adbackground: 0x000000, // ad box background
playbuttonbackground: 0x333333, // play button background
playbuttontext: 0xFFFFFF, // play button text color
playbuttonborder: 0xFFFFFF // play button border color
*/
});
addChild(wrapper);
}
// required for OpenFL ApplicationMain.hx
override public function onUpdate(bytesLoaded:Int, bytesTotal:Int)
{
}
// required for OpenFL ApplicationMain.hx
override public function onInit()
{
}
// required for OpenFL ApplicationMain.hx
override public function onLoaded()
{
}
// called when the ad closes or errors, OpenFL then proceeds
// to add your own document class to the stage as normal
private function adFinished(e:Event)
{
dispatchEvent (new Event (Event.COMPLETE));
}
private function dispose(e:Event)
{
removeEventListener(Event.ADDED_TO_STAGE, init);
removeEventListener(Event.REMOVED_FROM_STAGE, dispose);
}
}