Change stage background color in AS3?

2020-07-02 10:38发布

I am using pure AS3 to build my project. I was wondering if there are anyways to change the stage background color through AS3...Thanks for the help....

8条回答
▲ chillily
2楼-- · 2020-07-02 11:22

I have this in a creationComplete handler

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               creationComplete="on_init();">

private function on_init():void {
    stage.color = 0x000000;
}

Though I have a feeling it would work anywhere.

查看更多
疯言疯语
3楼-- · 2020-07-02 11:25

You can set background colour on initialization, the way @Wopdoowop mentioned, but if you want to change it dynamically you would need to create your own bitmap/sprite/movieclip that would act as a background (should go below the rest of your content and have width and height of your stage) and change colour of that bitmap/sprite/movieclip.

查看更多
登录 后发表回答