Yes, that's very possible.
There are two options for this.
(1) To use a perpetually tiled background by using a piece of code such as this (uses BitmapData class)
Code:
import flash.display.BitmapData;
centerimg._x = Stage.width/2;
centerimg._y = Stage.height/2;
var tile:BitmapData = BitmapData.loadBitmap("tile")
function fillBG() {
this.beginBitmapFill(tile);
this.moveTo(0,0);
this.lineTo(Stage.width,0);
this.lineTo(Stage.width,Stage.height);
this.lineTo(0,Stage.height);
this.lineTo(0,0);
this.endFill();
}
fillBG();
var stageL:Object = new Object();
stageL.onResize = function() {
fillBG();
centerimg._x = Stage.width / 2;
centerimg._y = Stage.height / 2;
}
This will apply a tiled background that doesn't stretch but rather keeps refilling the screen and also centers the content (called centerimg in this example) and doesn't scale it.
for this to work properly, put your background clip into the library and give it a linkage identifier of "tile" (or whatever else you choose, just make sure to update the AS)
(2) If you want a solid color as your background, or a scaleable movieclip use fluid dynamics with a code like this.
Code:
Stage.align = "TL";
Stage.scaleMode = "noScale";
background_mc._x = 0
background_mc._y = 0
background_mc._width = Stage.width
background_mc._height = Stage.height
content_mc._x = Stage.width/2
content_mc._y = Stage.height/2
sizeListener = new Object();
sizeListener.onResize = function() {
background_mc._x = 0
background_mc._y = 0
background_mc._width = Stage.width
background_mc._height = Stage.height
content_mc._x = Stage.width/2
content_mc._y = Stage.height/2
};
Stage.addListener(sizeListener);
This is will your content in the center if the user resizes the screen also.
If you have already created your flash movie and it will be too tedious to change all the AS to reflect this path change:
- create a new .fla
- use the above AS
- create a moveclip (instance name content_mc) and use loadMovie(); to import your existing .swf
Bookmarks