diff --git a/buildfiles/html5/haxe/ApplicationMain.hx b/buildfiles/html5/haxe/ApplicationMain.hx
index 546bb9604..232f2ec2e 100755
--- a/buildfiles/html5/haxe/ApplicationMain.hx
+++ b/buildfiles/html5/haxe/ApplicationMain.hx
@@ -1,204 +1,31 @@
-#if (!lime && !flambe)
+#if lime_html5
+
+ import ::APP_MAIN_PACKAGE::::APP_MAIN_CLASS::;
+ import lime.LiME;
+
+ class ApplicationMain {
+
+ public static function main () {
-import ::APP_MAIN_PACKAGE::::APP_MAIN_CLASS::;
-import nme.display.Bitmap;
-import nme.display.Loader;
-import nme.events.Event;
-import nme.media.Sound;
-import nme.net.URLLoader;
-import nme.net.URLRequest;
-import nme.net.URLLoaderDataFormat;
-import nme.Assets;
-import nme.Lib;
-
-
-class ApplicationMain {
-
-
- private static var completed:Int;
- private static var preloader:NMEPreloader;
- private static var total:Int;
-
- public static var loaders:Hash ;
- public static var urlLoaders:Hash ;
-
-
- public static function main () {
-
- completed = 0;
- loaders = new Hash ();
- urlLoaders = new Hash ();
- total = 0;
-
- ::if (WIN_WIDTH == "0")::::if (WIN_HEIGHT == "0")::
- browser.Lib.preventDefaultTouchMove ();
- ::end::::end::
-
- ::if (PRELOADER_NAME!="")::
- preloader = new ::PRELOADER_NAME:: ();
- ::else::
- preloader = new NMEPreloader ();
- ::end::
- Lib.current.addChild (preloader);
- preloader.onInit ();
-
- ::foreach assets::
- ::if (type=="image")::
- var loader:Loader = new Loader ();
- loaders.set ("::resourceName::", loader);
- total ++;
- ::elseif (type == "binary")::
- var urlLoader:URLLoader = new URLLoader ();
- urlLoader.dataFormat = BINARY;
- urlLoaders.set ("::resourceName::", urlLoader);
- total ++;
- ::elseif (type == "text")::
- var urlLoader:URLLoader = new URLLoader ();
- urlLoader.dataFormat = TEXT;
- urlLoaders.set ("::resourceName::", urlLoader);
- total ++;
- ::end::::end::
-
- if (total == 0) {
- begin ();
+ //Create the game class, give it the runtime
+ var _main_ = Type.createInstance (::APP_MAIN::, []);
+ //Create an instance of lime
+ var _lime = new LiME();
+
+ //Create the config from the project.nmml info
+ var config = {
+ width : ::WIN_WIDTH::,
+ height : ::WIN_HEIGHT::,
+ title : "::APP_TITLE::"
+ };
+
+ //Start up
+ _lime.init( _main_, config );
- } else {
-
- for (path in loaders.keys ()) {
-
- var loader:Loader = loaders.get (path);
- loader.contentLoaderInfo.addEventListener ("complete", loader_onComplete);
- loader.load (new URLRequest (path));
-
- }
-
- for (path in urlLoaders.keys ()) {
-
- var urlLoader:URLLoader = urlLoaders.get (path);
- urlLoader.addEventListener ("complete", loader_onComplete);
- urlLoader.load (new URLRequest (path));
-
- }
-
- }
-
- }
-
-
- private static function begin ():Void {
-
- preloader.addEventListener (Event.COMPLETE, preloader_onComplete);
- preloader.onLoaded ();
-
- }
-
-
- public static function getAsset(inName:String):Dynamic {
-
- ::foreach assets::
- if (inName=="::id::") {
- ::if (type == "image")::
- return Assets.getBitmapData ("::id::");
- ::elseif (type=="sound")::
- return Assets.getSound ("::id::");
- ::elseif (type=="music")::
- return Assets.getSound ("::id::");
- ::elseif (type== "font")::
- return Assets.getFont ("::id::");
- ::elseif (type== "text")::
- return Assets.getText ("::id::");
- ::else::
- return Assets.getBytes ("::id::");
- ::end::
- }
- ::end::
- return null;
-
- }
-
-
-
-
- // Event Handlers
-
-
-
-
- private static function loader_onComplete (event:Event):Void {
-
- completed ++;
-
- preloader.onUpdate (completed, total);
-
- if (completed == total) {
-
- begin ();
-
- }
-
- }
-
-
- private static function preloader_onComplete (event:Event):Void {
-
- preloader.removeEventListener (Event.COMPLETE, preloader_onComplete);
-
- Lib.current.removeChild(preloader);
- preloader = null;
-
- if (Reflect.field(::APP_MAIN::, "main") == null)
- {
- var mainDisplayObj = new ::APP_MAIN::();
- if (Std.is(mainDisplayObj, browser.display.DisplayObject))
- nme.Lib.current.addChild(cast mainDisplayObj);
- }
- else
- {
- Reflect.callMethod (::APP_MAIN::, Reflect.field (::APP_MAIN::, "main"), []);
- }
-
- }
-
-
-}
+ } //main
+ } //ApplicationMain
-::foreach assets::
- ::if (type=="font")::
- class NME_::flatName:: extends nme.text.Font { }
- ::end::
-::end::
-
-
-#else
-
-
-import ::APP_MAIN_PACKAGE::::APP_MAIN_CLASS::;
-import lime.LiME;
-
-class ApplicationMain {
-
- public static function main () {
-
- //Create the game class, give it the runtime
- var _main_ = Type.createInstance (::APP_MAIN::, []);
- //Create an instance of lime
- var _lime = new LiME();
-
- //Create the config from the project.nmml info
- var config = {
- width : ::WIN_WIDTH::,
- height : ::WIN_HEIGHT::,
- title : "::APP_TITLE::"
- };
-
- //Start up
- _lime.init( _main_, config );
-
- } //main
-} //ApplicationMain
-
-
-#end
\ No newline at end of file
+#end //lime_html5
diff --git a/buildfiles/html5/haxe/NMEPreloader.hx b/buildfiles/html5/haxe/NMEPreloader.hx
new file mode 100644
index 000000000..e1bab587f
--- /dev/null
+++ b/buildfiles/html5/haxe/NMEPreloader.hx
@@ -0,0 +1,113 @@
+// import flash.display.Sprite;
+// import flash.events.Event;
+
+
+class NMEPreloader // extends Sprite
+{
+ // private var outline:Sprite;
+ // private var progress:Sprite;
+
+ public function new()
+ {
+ // super();
+
+ // var backgroundColor = getBackgroundColor ();
+ // var r = backgroundColor >> 16 & 0xFF;
+ // var g = backgroundColor >> 8 & 0xFF;
+ // var b = backgroundColor & 0xFF;
+ // var perceivedLuminosity = (0.299 * r + 0.587 * g + 0.114 * b);
+ // var color = 0x000000;
+
+ // if (perceivedLuminosity < 70) {
+
+ // color = 0xFFFFFF;
+
+ // }
+
+ // var x = 30;
+ // var height = 9;
+ // var y = getHeight () / 2 - height / 2;
+ // var width = getWidth () - x * 2;
+
+ // var padding = 3;
+
+ // outline = new Sprite ();
+ // outline.graphics.lineStyle (1, color, 0.15, true);
+ // outline.graphics.drawRoundRect (0, 0, width, height, padding * 2, padding * 2);
+ // outline.x = x;
+ // outline.y = y;
+ // addChild (outline);
+
+ // progress = new Sprite ();
+ // progress.graphics.beginFill (color, 0.35);
+ // progress.graphics.drawRect (0, 0, width - padding * 2, height - padding * 2);
+ // progress.x = x + padding;
+ // progress.y = y + padding;
+ // progress.scaleX = 0;
+ // addChild (progress);
+ }
+
+
+ public function getBackgroundColor():Int
+ {
+ return ::WIN_BACKGROUND::;
+ }
+
+
+ public function getHeight():Float
+ {
+ var height = ::WIN_HEIGHT::;
+
+ if (height > 0) {
+
+ return height;
+
+ } else {
+
+ return 640;// flash.Lib.current.stage.stageHeight;
+
+ }
+ }
+
+
+ public function getWidth():Float
+ {
+ var width = ::WIN_WIDTH::;
+
+ if (width > 0) {
+
+ return width;
+
+ } else {
+
+ return 960;// todo flash.Lib.current.stage.stageWidth;
+
+ }
+ }
+
+
+ public function onInit()
+ {
+
+ }
+
+
+ public function onLoaded() {
+ // dispatchEvent (new Event (Event.COMPLETE));
+ }
+
+
+ public function onUpdate(bytesLoaded:Int, bytesTotal:Int) {
+
+ var percentLoaded = bytesLoaded / bytesTotal;
+
+ if (percentLoaded > 1)
+ {
+ percentLoaded == 1;
+ }
+
+ progress.scaleX = percentLoaded;
+ }
+
+
+}
\ No newline at end of file
diff --git a/buildfiles/html5/template/index.html b/buildfiles/html5/template/index.html
index 1ad943b34..03f4da944 100755
--- a/buildfiles/html5/template/index.html
+++ b/buildfiles/html5/template/index.html
@@ -3,6 +3,17 @@
::APP_TITLE::
+
+
@@ -24,7 +35,7 @@
::end::
::if DEBUG::::end::
-