开发者

How do I change the size and color of the stage in actionscript 3?

开发者 https://www.devze.com 2022-12-09 16:19 出处:网络
AFAIK, in AS2 it was \"Stage.height = x;\".开发者_JAVA技巧From documentation of flash.display.stage in AS3:

AFAIK, in AS2 it was "Stage.height = x;".开发者_JAVA技巧


From documentation of flash.display.stage in AS3:

The Stage object is not globally accessible. You need to access it through the stage property of a DisplayObject instance.

Also refer to this: Setting Stage properties


Depends on how you are compiling your .swf, but it is completely possible. If you are building a Flex project, you can set the backgroundColor property of the Application or use a css file to change it. e.g.

<mx:Application 
    backgroundColor="#000000" 
    width="500"
    height="500"
    layout="absolute"
    xmlns:mx="http://www.adobe.com/2006/mxml">

</mx:Application>

If you are building in Flex (an "Actionscript Project") or using the mxmlc compiler, you can use the undocumented "SWF" metadata tag, e.g.

package
{
    [SWF(width="500", height="500", backgroundColor="#000000")]
    public class MyApp extends Sprite
    {

    }
}

And of course, if you're using Flash "the application", you can just click the stage and then go to the properties panel and set the width, height, and background color.


You really can't... the background color is not really a stage property, you should work-around it by changing some background clip. As for the size, in AIR you can directly change the NativeWindow dimesions, but in a browser you need to use javascript to change the object's size:

document.getElementById("myFlash").height=100;

You could use stage.width = 100, but it will only change the displayobject's dimensions, truncating its content, and leaving an empty space next to it... Actually Stage.width is read-only in AS3 and AS2.


This is easy. In the main CData block, "this" is the application object. Then:

this.setStyle("backgroundColor", 0xff0000);

This is much better than starting to creates sprites and rendering with the graphics layer, since presumably the best performance is with a flat fill in the absence of any objects in front.

0

精彩评论

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

关注公众号