Bitmap aspect ratio question

Hi Kirupa,

I found a thread in that resizes a bg image beautifully (without any pixelation whatsoever), except that there is a minor glitch in the script that doesn’t load properly. What does the solution mean: “try waiting until after the image is loaded. call your setBackground(); function from the onLoadInit”

Here is the script:

import flash.display.*;
// this tells Flash NOT to allow the assets to be scaled
Stage.scaleMode = “noScale”;
Stage.align = “TL”;

// need to set up a listener object to say when the stage is resized.
var stageListener:Object = new Object();


// called when the stage is resized
stageListener.onResize = function() {

function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(“bmc”,target.getNextHi ghestDepth());

// Create a listener which will notify us when the bitmap loaded successfully
var listener:Object = new Object();
// Track the target
listener.tmc = target;

// If the bitmap loaded successfully we redraw the movie into
// a BitmapData object and then attach that BitmapData to the target
// movie clip with the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
mc._visible = false;
var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(),“auto”, true);

// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.loadClip(url, bmc);

// Sample code

createEmptyMovieClip(“mc1”, getNextHighestDepth());
mc1.createEmptyMovieClip(“mc”, mc1.getNextHighestDepth());
function setBackground() {

// determine middle
var middleX = Stage.width/2;
var middleY = Stage.height/2;

// scale background to fit width and height = Stage.width; = Stage.height;

// see if it grew bigger horizontally or vertically and adjust other to match
// to maintain aspect ratio > ? = : =;


The full thread can be seen here:…php3?t=139207

Any help is kindly appreciated. Tks.