Note that there are some explanatory texts on larger screens.

plurals
  1. POResizing image using as3
    primarykey
    data
    text
    <p>I am building a portfolio site which dynamically loads large hi-res images when the user clicks on a thumnail. However I'm having problems maintaining the original image's quality when resizing it to fit the current browser. </p> <p>Currently I'm just adjusting the width &amp; height properties of the image to width to the stage proportionally which is working fine getting it to fit, however I cannot figure out how to maintain image quality? Do I need to load it as a bitmap and redraw/smooth or something similar?</p> <p>This is the appropriate code that I am currently using:</p> <pre><code>var req:URLRequest = new URLRequest("images/101.jpg"); var loader:Loader = new Loader(); var widthRatio:Number; var heightRatio:Number; function imageLoaded(e:Event):void { //add image to stage addChild(loader); // resize proportionally if (loader.width &gt; stage.stageWidth){ widthRatio=loader.width/stage.stageWidth; trace(widthRatio) trace(loader.width); } if (loader.height &gt; stage.stageHeight){ heightRatio=loader.height/stage.stageHeight; trace(heightRatio) trace(loader.height) } if (widthRatio &gt; heightRatio){ loader.width = stage.stageWidth; loader.height = loader.height/widthRatio; } else { loader.height = stage.stageHeight; loader.width = loader.width/heightRatio; } //centre on stage loader.x=stage.stageWidth/2 - loader.width/2; loader.y=stage.stageHeight/2 - loader.height/2; } loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded); loader.load(req); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload