import nme.display.Sprite;
import nme.events.Event;


class NMEPreloader extends Sprite
{
	private var outline:Sprite;
	private var progress:Sprite;
   var preWidth:Float;
   var preHeight:Float;
   var backgroundColor:Int;
   var onLoaded:Void->Void;
	
	
	public function new(inWidth:Float, inHeight:Float, inCol:Int, inOnLoaded:Void->Void)
	{
		super();
      preWidth = inWidth > 0 ? inWidth : nme.Lib.current.stage.stageHeight;
      preHeight = inHeight > 0 ? inHeight : nme.Lib.current.stage.stageHeight;
		backgroundColor = inCol;

		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 getHeight():Float
	{
		var height = ::WIN_HEIGHT::;
		
		if (height > 0) {
			
			return height;
			
		} else {
			
			
		}
	}
	
	
	public function getWidth():Float
	{
		var width = ::WIN_WIDTH::;
		
		if (width > 0) {
			
			return width;
			
		} else {
			
			return nme.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;
	}

	
}

Work on flash resources and preloader
Work on flash resources and preloader

thomasuster/NME,haxenme/nme,nmehost/nme,madrazo/nme,haxenme/nme,madrazo/nme,haxenme/nme,madrazo/nme,nmehost/nme,madrazo/nme,haxenme/nme,madrazo/nme,madrazo/nme,thomasuster/NME,thomasuster/NME,nmehost/nme,thomasuster/NME,thomasuster/NME,haxenme/nme,thomasuster/NME