Posts Tagged ‘Stage’

AS3 Stage Preloader / Loader

Monday, January 18th, 2010

Happy new year :)
Here’s a AS3 preloader.


this.loaderInfo.addEventListener(ProgressEvent.PROGRESS , onLoadProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);

function onLoadProgress(event:ProgressEvent):void {
	var bl:uint = event.bytesLoaded;
	var bt:uint = event.bytesTotal;
	var percentLoaded:int = Math.floor((bl/bt) * 100);
	trace( String(percentLoaded) ); //trace percent loaded
}

function onLoadComplete(event:Event):void {
	trace("loading complete!"); //trace load completed
}
Vote in HexoSearch

AS3 Stage.width Stage.height Example

Monday, June 22nd, 2009

Adobe has changed the syntax in AS3 for AS2 Stage.width/Stage.height equivalence (see below).

Code examples:

stage.stageWidth;
stage.stageHeight;

Getting the middle of the stage.

stage.stageWidth/2
stage.stageHeight/2

Aligning your “MovieClip” into the middle of the stage.

MovieClip.x=stage.stageWidth/2-MovieClip.width/2;
MovieClip.y=stage.stageHeight/2-MovieClip.height/2;

You don’t need to add the brackets – Replace “MovieClip” above with your MC instance name – That’s it you ready to roll.

Vote in HexoSearch
  • Categories

  • Recent Comments

  • Recent Posts

  • Tumblr

  • Flickr Recent Photos

    cherry tree woodstonja_gravestonesPockey Chimp FlavourAUTO FTW! :)darkdaystayouttiger kittenbirdofpreyfirst photo i took with my 1000dself_portrait_02
  • XFIRE (wkly hrs pld)

  • Last.FM

  • Tags

    .MP4 Actionscript Action Script Advertising AS2 AS3 backtrack BT4 bug Call of Duty capcom centOS COD count down countdown crossdomain Eyeblaster eyeblaster HD f4v Flash h264 HD high definition Install internet explorer Linux loadMovie MIME MIME Types MW2 Nazi Zombies pc PHP ports preloader release date rich media shared objects SWF SWFOBJECT timer torrents Video video/mp4 win7