You can set the default background color in a few ways:
FP.screen.color = 0x000000;
or, in your Main
class (or whatever you decided to name it):
[SWF(width="YOURWIDTH", height="YOURHEIGHT", backgroundColor="#000000")]
or you can set it in the metadata of the swf itself (your IDE should be able to do this)
Or, you could just create a giant Image
for your background:
var bg:Image = Image.createRect(FP.width, FP.height, 0x000000);
add(bg);
I think your main menu should be a World
. There are only a few times where I would recommend making it an Entity
instead, and your situation doesn’t sound anything like any of those.
In terms of making it fade out, you can create another full-screen Image
on top of the rest of your Entities
and use a Tween
to fade it out:
var fade:Image = Image.createRect(FP.width, FP.height, 0x000000);
fade.alpha = 0;
add(fade);
var fadeTween:VarTween = new VarTween();
fadeTween.complete = function():void{
FP.world = new GameWorld;
}
Then, when you’re ready to load the game world:
fadeTween.tween(fade, "alpha", 0, FADE_TIME);
You might also want to do the opposite (have a tween from alpha 0 to 1) at the beginning of GameWorld
depending on your game.
Another thing to look into is punk.transition, which allows you to create smooth transitions between Worlds
. One of the default transitions is a fading transition.