Created
June 30, 2010 05:00
-
-
Save mattupstate/458254 to your computer and use it in GitHub Desktop.
This file contains 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.Bitmap; | |
import flash.display.Sprite; | |
public class CenteredImage extends Sprite | |
{ | |
private var _image:Bitmap; | |
public function CenteredImage( image:Bitmap ) | |
{ | |
_image = image; | |
_image.x = _image.y = 0; | |
addChild( _image ); | |
addEventListener( Event.ADDED_TO_STAGE, onAddedToStage ); | |
} | |
private function onAddedToStage( event:Event ):void | |
{ | |
x = parent.width * 0.5 - width * 0.5; | |
y = parent.height* 0.5 - height * 0.5; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment