Skip to content

Instantly share code, notes, and snippets.

@cccaldas
Created August 30, 2012 03:05
Show Gist options
  • Save cccaldas/3521933 to your computer and use it in GitHub Desktop.
Save cccaldas/3521933 to your computer and use it in GitHub Desktop.
public function align(width:Number, height:Number, scale:Boolean=false):void {
if(scale) {
var percent:Number = width / _width;
this.scaleX = this.scaleY = percent;
if(this.height > height) {
percent = height / _height;
this.scaleX = this.scaleY = percent;
}
}
this.x = (width - this.width) * .5;
this.y = (height - this.height) * .5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment