Use code to change background color in AS3?

Moshe picture Moshe · Nov 9, 2010 · Viewed 13k times · Source

Is it possible to change the stage's background through actionscript?

How do I do it? (Code please.)

Answer

Jordan picture Jordan · Nov 10, 2010

The stages background color can be changed using its graphics object.

If you have a reference to the stage:

stage.graphics.beginFill( 0x00FF00 );
stage.graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight );
stage.graphics.endFill();

If this is in your document class:

graphics.beginFill( 0x00FF00 );
graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight );
graphics.endFill();