How do I scale a loaded image

Posted on 2009-12-16
Last Modified: 2013-11-11
I have loaded an image with the Loader-class

var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("");

How do I scale the original image, so it fits better.
Question by:petersego
    1 Comment
    LVL 19

    Accepted Solution

    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("");
    loader.contentLoaderInfo.addEventListener("complete", completeHandler);
    function completeHandler(event:Event):void{
      loader.width = 100;
      loader.height = 200;

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now