Created
April 3, 2010 04:58
-
-
Save troygilbert/354131 to your computer and use it in GitHub Desktop.
MyAppPreloader.as
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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