var image:Loader = new Loader();
image.load(new URLRequest("http://www.shapevent.com/sketchbook/wp-content/uploads/avalanche.jpg"));
image.x = stage.stageWidth / 2;
image.y = stage.stageHeight / 2;
addChild(image);
image.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(evt:Event):void {
// CENTER THE IMAGE
image.content.x = -image.content.width / 2;
image.content.y = -image.content.height / 2;
// BITMAP SMOOTHING
Bitmap(image.content).smoothing = true;
image.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
}
// scale the image with the mouse to demonstrate smoothing and scaling from the center
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
image.scaleX = image.scaleY = mouseX / stage.stageWidth;
}
This is really two snippets combined. How to scale the content of a Loader from the center:
// CENTER THE IMAGE image.content.x = -image.content.width / 2; image.content.y = -image.content.height / 2;
and how to smooth a jpg, png etc… that has been loaded dynamically into your swf:
// BITMAP SMOOTHING Bitmap(image.content).smoothing = true;
