Skip to content

Instantly share code, notes, and snippets.

@troygilbert
Created April 3, 2010 04:58
Show Gist options
  • Save troygilbert/354131 to your computer and use it in GitHub Desktop.
Save troygilbert/354131 to your computer and use it in GitHub Desktop.
MyAppPreloader.as
package
{
import flash.display.Graphics;
import flash.display.TextField;
public class MyAppPreloader extends Preloader
{
/** Text display of progress. **/
protected var tf:TextField;
/** Constructor. **/
public function Preloader()
{
super("com.mycompany.myapp.Application");
}
/** Add preloader -- override this to add your own animated elements. **/
override protected function addPreloader():void
{
super.addPreLoader();
// add a white background
var g:Graphics = preloader.graphics;
g.clear();
g.beginFill(0xffffff);
g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
g.endFill();
// textfield
tf = new TextField();
preloader.addChild(tf);
}
/** Update preloader -- override this to update your animated elements. **/
protected function updatePreloader(progress:Number):void
{
tf.text = int(progress * 100).toString();
}
/** Remove preloader -- override this to remove the elements added in addPreloader(). **/
protected function removePreloader():void
{
preloader.removeChild(tf);
tf = null;
super.removePreloader();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment