[Solved] SWF (Flash) Size wrong when used in iScreensaver

When a SWF file is used within iScreensaver, it is loaded as follows:

  • It begins in the PAUSED state
  • it is loaded into a window, the size of which may not match the screen exactly
  • the window is adjusted in size to meet the screen
  • It is given the PLAY command.

To make sure your SWF file works properly, you should do these things:

  • Make sure the SWF file does not start playing immediately, and responds to the Play/Pause commands. To test this, you can load your SWF file within Adobe Flash Player. If the animation begins immediately (or the Control menu does not allow you to choose Play/Pause) then you have a problem.

  • Make sure the SWF file does not start playing before the window resizes. If you notice any issues with the animation content not matching the screen exactly, you may have this issue.

The solution in either case:

  • Insert some blank frames (perhaps 0.25 to 0.5 seconds worth) BEFORE the first animation frame in your SWF.

  • In these blank frames, put a single rectangle that matches the size of the stage and is filled with the background color of your choice. (This is important so that iScreensaver can detect the “natural size” of your SWF animation, used for computing aspect ratios in the various stretch modes)

  • Verify that you have succeeded by loading the new SWF inside iScreensaver Designer, and opening the preview window. If it works, you should see

  • the animation pauses when in pause mode, and plays when in play mode
  • the SWF width and height were properly detected at the correct size (to see the Width/Height values, switch to List view, or right click the item and choose Item/Media, then open the Compression tab and verify the width, height values match your file.

Additional Notes:

  • do NOT attempt to enter full screen mode using [fscommand (“fullscreen”, “true”)] – this will cause a security violation on many systems and may also cause the screensaver to malfunction.

  • do NOT attempt to adjust the window size. Your SWF should be passive, allowing iScreensaver to set the window size.

UPDATE: if you are trying to use dynamic stage sizing, please note that under Flash / ActionScript 3, the Stage.StageWidth / State.StageHeight values may not be what you expect. It turns out that these values generally report to you the ORIGINAL stage size, rather than the actual stage size based on the size of the window or screen.

To work around this, you may want to use the NO_SCALE and TOP_LEFT modes, and put an event listener on the RESIZE event. These techniques are described here:
http://www.actionscript.org/forums/showthread.php3?t=241576
and here:
http://stackoverflow.com/questions/833466/dynamic-stagewidth-and-height-in-flash-as3

e.g.

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, onResize);
function onResize(e:Event=null):void
{
trace( stage.stageWidth );
// in this function, set the location and sizes of the various animations/movie clips, etc.
// note: under iScreensaver, this event may be called several times with a variety of widths & heights as the window is resized to the final size, so you may want to add some logic here to wait until the final width/height are available. For example, you could just remember the width/height values in a global variable, and then use these values about 1/2 second into your timeline (e.g. on frame 15 if you are using 30fps timeline).
}

Update: please note that the technique you choose may depend on whether you are using LETTERBOX or FILL screen modes inside iScreensaver, and whether you are doing any dynamic resizing or rescaling of objects using Actionscript. If you are, please check out this thread which describes a slightly different approach:

http://iscreensaver.com/forum/discussion/159/screen-size-issue-on-the-pc