开发者

How to set different properties on stage programmatically?

I want to set the height, width and backgroundcolor, etc on stage programmatically in a pure AS project. I'm not really sure about how to do that.

I tried to set the height and wi开发者_JAVA百科dth like that but it failed..

stage.align = StageAlign.LEFT;
            stage.height = 400; 
            stage.width = 500;


The stage inherits whatever size you drag and expand it to when published. It doesn't really make sense to "set" it since you can resize it however you want externally. If it's in an HTML page, just set your HTML element/div width/height and the SWF will inherit whatever size the element/div ends up being. On the other hand, if it's a Flex/AIR app and is used in a standalone non-browser context, that's a little different:

[SWF(width='800',height='600',backgroundColor='#000000',frameRate='30')]

That's Flex-specific though and cannot be used in a regular Flash project.

If it's regular Flash though, it seems like you're thinking it out in the wrong way. Resize this page as an example - the stage resizes to the full browser width/height and the textfield just re-center's itself based on that size.


In a pure AS project in Flash Builder, the [SWF(...)] line from jpea's answer is valid too. The only thing to keep in mind is that setting it at runtime won't work for the width and height of the stage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜