Hi guys... 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....
Thanks...would you please explain more details? I have tried google but couldn't find anything.....Thanks.
Jerry
2010-08-07 23:40:16
+2
A:
like this:
[SWF(backgroundColor="0xec9900")]
public class Main extends Sprite
{
}
PatrickS
2010-08-08 06:49:22
+3
A:
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.
negative
2010-08-08 08:01:57
+1
A:
This creates a shape and add it to the stage behind everything. To change the color anytime call: changeBGColor(0xFF0000)
(to red)
It also maintains the size of the background (covering all area) when the windows is resized.
import flash.display.Sprite;
import flash.events.Event;
var default_bg_color:uint = 0xffffff;
var bgshape:Sprite;
stage.align = "TL";
stage.scaleMode = "noScale";
function initBG()
{
bgshape = new Sprite();
bgshape.graphics.beginFill(default_bg_color);
bgshape.graphics.drawRect(0,0,stage.stageWidth, stage.stageHeight);
addChildAt(bgshape, 0);
stage.addEventListener(Event.RESIZE, resizeBGWithStage);
}
function changeBGColor(color:uint)
{
bgshape.graphics.beginFill(color);
bgshape.graphics.drawRect(0,0,stage.stageWidth, stage.stageHeight);
}
function resizeBGWithStage(e:Event)
{
try {
bgshape.width = stage.stageWidth;
bgshape.height = stage.stageHeight;
} catch(e){}
}
initBG();
Makram Saleh
2010-08-08 08:24:19