Richard Parnaby-King

Web Developer – PHP, Zend Framework and Actionscript 3

Posted on | | No Comments

So you have a flash application that looks great in a webpage, but when you view the .swf file directly in the browser it stretches and distorts and looks plain ugly. Fortunately, there is a solution!

Solution

By default your flash application will attempt to fill the container it is in, regardless of the width and height settings you have set. It is possible to tell your application ‘Oi! NO!’ by adding this line into your script:
[javascript]
stage.scaleMode = StageScaleMode.NO_SCALE;
[/javascript]

If you are including this in a .as file then you will also need to include StageScaleMode:
[javascript]
import flash.display.StageScaleMode;
[/javascript]

Examples

Here are a couple of examples. The first one does not have stage.scaleMode line of code, while the second does. These are direct links to the .swf files so will both fill the width and height of the browser you are viewing them with.

Without the fix
With scaleMode set

As you can see, the image in the first one has been stretched with the .swf file.
The second one, the one with scaleMode set, shows the image at the correct size, without any scaling what so ever.

Posted By:

Comments

  • ABOUT

    Having fifteen years of programming experience in PHP, Zend Framework and ActionScript3, I have a very strong working knowledge of object orientated programming.

    I am a PC Gamer! Playing FPS, RTS, RPG and the occasional MMO since 1996 I have a huge number of a variety of fast-paced games.

  • Recent Posts

  • Categories

  • SUBSCRIBE TO OUR FEED