• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

How do I scale a loaded image

I have loaded an image with the Loader-class

var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("http://www.helpexamples.com/flash/images/image1.jpg");
loader.load(url);

How do I scale the original image, so it fits better.
0
petersego
Asked:
petersego
1 Solution
 
moagriusCommented:
you can use the scaleX and scaleY properties.

scaleX is horizontal, scaleY is vertical

1 is original size, 0.5 is half, 2 is double, etc.

so loader.scaleX = 1.2 would make the images 120% as wide

if you want to use height or width, you can but need to wait until the image has loaded.  normally this would happen in the complete event handler, like so:
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("http://www.helpexamples.com/flash/images/image1.jpg");
loader.contentLoaderInfo.addEventListener("complete", completeHandler);
loader.load(url); 
function completeHandler(event:Event):void{
  loader.width = 100;
  loader.height = 200;
}

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now