import km.preloaders.*;

var _pl_ = new GradientBarPreloader();

_pl_.dx = 0; // delta x from center
_pl_.dy = 0; // delta y from center
_pl_.progress_type = 0; // 0 = left > right, 1 = bottom > top, 2 = clockwise
_pl_.line_thickness = 2; // thickness of outlines (1 - 10)
_pl_.text_format = new TextFormat('Verdana',11,0x555555,true); // textformat for load progress
_pl_.text_align = 2; // 0 = top, 1 = middle, 2 = bottom
_pl_.display = 2; // 0 = no text, 1 = percentage loaded, 2 = KB loaded
_pl_.os_width = 100;
_pl_.os_height = 10;
_pl_.os_line_color = 0x999999;
_pl_.os_line_alpha = 0.3;
_pl_.os_fill_type = 1; // 0 = horizontal, 1 = vertical, 2 = radial
_pl_.os_fill_colors = [0xd0d0e0, 0xd0d0e0];
_pl_.os_fill_alphas = [1, 1];
_pl_.os_fill_ratios = [0x00, 0xff];
_pl_.os_roundness = 100; // 0 - 100
_pl_.is_padding = 0; // padding between outer and inner shape
_pl_.is_line_color = 0x999999;
_pl_.is_line_alpha = 0.3;
_pl_.is_fill_type = 1; // 0 = horizontal, 1 = vertical, 2 = radial
_pl_.is_fill_colors = [0x353535, 0xffffff];
_pl_.is_fill_alphas = [1, 1];
_pl_.is_fill_ratios = [0x00, 0xff];
_pl_.is_roundness = 100; // 0 - 100

// customize here

addChild(_pl_);

function _continue_(e:Event):void {
	for (var i:int = 0; i < numChildren; i++) removeChildAt(0);
	if (totalFrames > 3) gotoAndPlay(3) else gotoAndStop(3);
}

/*

loaderInfo.addEventListener('complete', _continue_);
loaderInfo.addEventListener('progress', _pl_.showProgress);
if (loaderInfo.bytesLoaded == loaderInfo.bytesTotal) _continue_(null);

*/

var _tm_ = new Timer(100);
_tm_.addEventListener('timer', _timer_);
_tm_.start();

function _timer_(e:Event):void {
                var loaded:uint = 4.7 * getTimer(); // 56K
	// var loaded:uint = 32.6 * getTimer(); // DSL
	// var loaded:uint = 131.2 * getTimer(); // T1
	var total:uint = loaderInfo.bytesTotal;
	if (loaded >= total){
		_tm_.reset();
		_continue_(null);
	} else {
		_pl_.showProgress(new ProgressEvent('progress',false,false,loaded,total));
	}
}
