Class com.bumpslide.util.TimelinePreloader

com.bumpslide.util.TimelinePreloader

Description

Preloads a timeline and dispatches events along the way We like to have a delay before we show a loading indicator, so we wait for the EVENT_SHOW_INDICATOR event before showing the load indicator. By default, this delay is set to 1 second. Once that delay is passed, you will notice that the EVENT_PRELOAD_PROGRESS event contains a property called 'adjustedPercent'. This is a percentage of remaining bytes offset by the amount loaded before the 1 second delay. You can choose to use this percentage to feed your load indicator if you want a bar that doesn't start at 50% or something similar. You can hide the progress bar and start your app reliably once the EVENT_PRELOAD_COMPLETE event is received.

Example Usage:

 
 
   var display_txt:TextField;
   var preloader:TimelinePreloader;
 
   function init() {
   	stop();
 		display_txt.autoSize = true;
 		display_txt._visible = false;
 	 	preloader = new TimelinePreloader( this );
 		preloader.addEventListener( TimelinePreloader.EVENT_SHOW_INDICATOR, Delegate.create( this, showProgressBar ) );
  	 	preloader.addEventListener( TimelinePreloader.EVENT_PRELOAD_PROGRESS, Delegate.create( this, updateProgressBar ) );
 		preloader.addEventListener( TimelinePreloader.EVENT_PRELOAD_COMPLETE, Delegate.create( this, hideProgressBarAndStartApp ) );
   	preloader.start();   
 	}
 
   function showProgressBar() {
		display_txt._visible = true;	
	}

	function updateProgressBar(e:Object) {
		var pct:String = Math.round( e.adjustedPercent*100 ) + "%";
		display_txt.text = "Loaded "+pct;
	}

	function hideProgressBarAndStartApp() {
		gotoAndStop("start");	
	}
 
   init();
 
You can remove or alter the indicator delay time with code such as:
   preloader.indicatorDelayTime = 0;
 

Field Index

addEventListener, dispatchEvent, dispatchQueue, EVENT_PRELOAD_COMPLETE, EVENT_PRELOAD_PROGRESS, EVENT_SHOW_INDICATOR, indicatorDelayTime, removeEventListener

Method Index

new TimelinePreloader()

start()

Constructor Detail

TimelinePreloader

function TimelinePreloader(timeline_mc:MovieClip)

Constructor

Parameters

timeline_mc

Field Detail

EVENT_SHOW_INDICATOR

static public EVENT_SHOW_INDICATOR:String

EVENT_PRELOAD_PROGRESS

static public EVENT_PRELOAD_PROGRESS:String

EVENT_PRELOAD_COMPLETE

static public EVENT_PRELOAD_COMPLETE:String

indicatorDelayTime

indicatorDelayTime:Number [Write Only]
Sets indicator delay time in milliseconds

addEventListener

addEventListener:Function

removeEventListener

removeEventListener:Function

dispatchEvent

dispatchEvent:Function

dispatchQueue

dispatchQueue:Function

Method Detail

start

public function start()

starts preloading