2.5. Scaling the Movie

Problem

You want to control how a movie fits in the Player, including the scaling.

Solution

Use the Stage.scaleMode property.

Discussion

The Flash Player defaults to a scale mode of “showAll” (except the test Player, which defaults to “noScale”). In “showAll” mode, the Flash movie scales to fit the Player while maintaining the movie’s original aspect ratio. The result is that the movie can have borders on the sides if the Player aspect ratio does not match the movie aspect ratio. You can set a movie to “showAll” mode, as follows:

Stage.scaleMode = "showAll";

The “noBorder” mode scales a movie to fit the Player while maintaining the original aspect ratio, but it forces the Player to display no borders around the Stage. If the aspect ratio of the Player does not match that of the movie, some of the movie will be cut off around the edges. You can set a movie to “noBorder” mode, as follows:

Stage.scaleMode = "noBorder";

The “exactFit” mode scales a movie to fit the Player and alters the movie’s aspect ratio, if necessary, to match that of the Player. The result is that the movie always exactly fills the Player, but the elements of the movie may be distorted. For example:

Stage.scaleMode = "exactFit";

In “noScale” mode, the movie is not scaled, and it maintains its original size and aspect ratio regardless of the Stage’s size. When you use the “noScale” mode, also set the movie’s alignment (see Recipe 2.6). For example:

Stage.scaleMode = "noScale";

The scaleMode property’s ...

Get Actionscript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.