View Full Version : Smooth Image Scaling in Flash 7

01-19-2010, 12:56 AM
Greetings ActionScript.org.

I'm a Flash newbie and I'm hoping you can get me past my final hurdle on this project: Scaling the image to the size of the movie.

I'm using the following code to load a jpg onto the stage:

Stage.scaleMode = "showAll";

var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.loadClip("Surfcat-1149741464.jpg", container);

// I hoped something like this would work but Stage.height is undefined in the debugger.
//container._height = Stage.height;
//container._width = Stage.width;

The picture seems to expand the size of "container" beyond the stage and you only see the top-left corner. I'd like to smoothly scale it to fit the size of the stage, while maintaining the aspect ratio.

Note that while I'm developing using Flash CS3 Pro, I am targeting Flash 7/AS2 by design for two reasons:

I want the movie to play, even if my visitors haven't updated their Flash Player since 2003 (http://en.wikipedia.org/wiki/Adobe_Flash_Player#History).
Flash 7 has smooth scaling built-in (http://actionscript.org/forums/showthread.php3?t=89255&highlight=smooth) as long as you choose "Best" quality.

Can anyone point me in the right direction?

01-20-2010, 05:22 PM
OK, I'm getting closer. I'm scaling the image to the stage (at least initially) but the smoothing isn't happening.

What does it take for force smoothing in Flash 7?

Here's what I've tried:

Publish Settings uses "Best" Quality
Set _quality to "BEST" in first frame's Actions.
Set movieClip.forceSmoothing to true.
Set movieClip._quality to "BEST", though documentation says this is unnecesary when global _quality is set.

I've read many times at ActionScript.org and in this famous blog post (http://www.kaourantin.net/2005/12/dynamically-loading-bitmaps-with.html) that Flash 7 smooths images as long as you set the quality to Best. I must be missing something. Any ideas?

Here's my latest code. It lives in the first frame's Actions:

Stage.scaleMode = "showAll";
_quality = "BEST";

var ImageHeight, ImageWidth;

var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());

container.forceSmoothing = true;
container._quality = "BEST";

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.loadClip("Christmas_In_July.jpg", container);

var MCListener = new Object();
MCListener.onLoadInit = function(container:MovieClip) {
ImageWidth = container._width;
ImageHeight = container._height;


var resizeFunction = function():Void {

if (ImageWidth > ImageHeight)
container._height = Math.round(ImageHeight * (Stage.width / ImageWidth));
container._width = Stage.width;
container._width = Math.round(ImageWidth * (Stage.height / ImageHeight));
container._height = Stage.height;