tags:

views:

182

answers:

5

Directly-linked .swf files, i.e not embedded in a web page, seem to render at 100% of the browser window size. Is it possible to specify in the .swf file itself dimensions for the .swf to display at?

Thanks all,

Richard.

A: 

The SWF will always be rendered at 100%, but if you're producing the swfs you can control the size of content within them.

David Caunt
OK thanks. Just to confirm: I can define content, say anchored top left, with a fixed display size, say 300px x 300px, with this content not changing size whatever the browser window size is? Also what happens if the .swf IS embedded in a page, with specified object width and height?
I believe so - I'm not 100% certain so probably best to give it a try and see
David Caunt
No, the swf will get scaled by default. You have to use a different stage scale mode. See my answer for details.
evilpenguin
A: 

Yes you can, with PHP you can use the function getimagesize() which works with SWF files and return its dimensions.

Roy Peleg
Oh, my bad. Just saw that I didn't understand your question properly. My answer isn't relevant.
Roy Peleg
A: 

I don't think there is a way to cause the SWF to open with a given dimensions if you'll point your browser directly to the file (http://www.mysite.com/somefile.swf). By doing that you tell the browser to do whatever it's default behavior when loading this file type (which can vary between browsers and computers).

Roy Peleg
A: 

You can stop the swf from scaling its content by choosing the stage scale mode. I think what you're looking for is stage.scaleMode = StageScaleMode.NO_SCALE. Then, the swf will not scale at all and display at it's initial dimensions. The default, however, is StageScaleMode.SHOW_ALL.

evilpenguin
+1  A: 

In AS2:

Add the following code at the second frame (leave the first frame blank, putting the code in the first frame might give you false values):

Stage.scaleMode = "noScale";

Then you can access the stage's width & height using:

var myWidth:Number = Stage.width;
var myHeight:Number = Stage.height;

Note that there is no underscore before the width and height properties. Put your entire movie inside a single movieclip at the root and set it's relative size according to these values.

Let me know if that worked for you. Also: See my answer about the downside of linking directly to SWF files.

Eliram