How do I set the width and height of my swf in AS3?

我们两清 提交于 2019-12-06 06:45:36

Try putting

[SWF(backgroundColor="#000000", width="200", height="400", frameRate="29")]

In the line above

public class Game extends Sprite {
....

Where you, of course, can set backgroundColor, width, height etc. To whatever you want.

Hope it helps!

I know you say you want to set the size via AS3, but is that necessary? Can't you just set the output properties. If you are publishing from Flash IDE you can go to Modify > Document, and set the width and height.

In your AS3 you can set the following properties, so when your SWF resizes, it is handled better.

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

EDIT

If you are using mxmlc in the command line to compile your SWF default size option:

default-size <width> <height>

For the most part, I believe SWF size is generally controlled by the web page it's embedded into. The SWF does not have direct access to these properties, but I believe you can use Javascript and call it from the SWF. Here is a link to a discussion about doing this: Actionscript Forums

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!