Actionscript:
-
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:
Actionscript:
-
// 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:
Actionscript:
-
// BITMAP SMOOTHING
-
Bitmap(image.content).smoothing = true;
3 Comments
Thank you for the articel…very good for learn…
thanks mate..,
really got that smoothing thingy..,
hahaha..,
Hey,
nice Post, only 1 suggestions:
If you are using the Bitmap smooth function in some cases you will get security errors, so you have to add:
var loadCon: LoaderContext = new LoaderContext(true);
and load by
image.load(requ , loadCon);
to check the policy files
… but anyway thanks for the Bitmapsmooth hint… i was not aware you can aply this inside a loader…