Hello.
I am using the seamlessBackground class from pixelfumes.com.
I am trying to make a website for myself at www.glitzphotography.com which I use the class.
The background displays the first images then just spreads it across the screen. It only appears correctly after you resize the screen.
Do you know what I mean? Can someone help me modify this script so it works correctly as soon as you load the screen not only after you resize the browser?
Thanks!
//Seamless Background Class
//Ben Pritchard 2006
//Pixelfumes.com
import flash.display.BitmapData;
class SeamlessBackground{
var stageWidth:Number;
var stageHeight:Number;
var scope:MovieClip;
var linkageID:String;
var clipWidth:Number;
var clipHeight:Number;
var stageListener:Object;
var centeredClip:MovieClip = null;
var tileCount:Number;
var useBitmap:Boolean;
function SeamlessBackground(s:MovieClip,linkage:String,useBMP:Boolean){
linkageID = linkage;
useBitmap = useBMP;
stageListener = new Object();
stageListener.cRef = this;
stageListener.onResize = function(){
this.cRef.updateTiles();
}
Stage.addListener(stageListener);
scope = s;
scope.createEmptyMovieClip("tile_1",1);
if(useBitmap != true){
scope["tile_1"].attachMovie(linkageID,"tile",1);
clipWidth = scope["tile_1"]._width;
clipHeight = scope["tile_1"]._height;
}else{
var bmpd:BitmapData = BitmapData.loadBitmap(linkageID);
with(scope["tile_1"]){
beginBitmapFill(bmpd, matrix, repeat, smoothing);
repeat = true;
moveTo(0, 0);
lineTo(0, Stage.height);
lineTo(Stage.width, Stage.height);
lineTo(Stage.width, 0);
lineTo(0, 0);
endFill();
}
}
}
public function setCenteredClip(mc:MovieClip):Void{
centeredClip = mc;
updateTiles();
}
private function updateTiles():Void{
if(useBitmap != true){
destroyTiles();
var fitsX:Number = Math.ceil(Stage.width/clipWidth);
var fitsY:Number = Math.ceil(Stage.height/clipHeight);
var colCount:Number = 1;
for(var x:Number=1; x<fitsX*fitsY; x++){
scope.createEmptyMovieClip("tile_"+(x+1),x+1);
var nClip:MovieClip = scope["tile_"+(x+1)];
nClip.attachMovie(linkageID,"tile",1);
var lClip:MovieClip = scope["tile_"+x];
if(colCount+1 > fitsX){
colCount = 0;
nClip._x = 0;
nClip._y = lClip._y + lClip._height;
}else{
nClip._x = lClip._x + lClip._width;
nClip._y = lClip._y;
}
colCount++;
}
tileCount = fitsX*fitsY;
}else{
var bmpd:BitmapData = BitmapData.loadBitmap(linkageID);
with(scope["tile_1"]){
clear();
beginBitmapFill(bmpd, matrix, repeat, smoothing);
moveTo(0, 0);
lineTo(0, Stage.height);
lineTo(Stage.width, Stage.height);
lineTo(Stage.width, 0);
lineTo(0, 0);
endFill();
}
}
if(centeredClip != null){
centeredClip._x = (Stage.width/2)-centeredClip._width/2;
centeredClip._y = (Stage.height/2)-centeredClip._height/2;
}
}
public function destroyTiles():Void{
for(var x:Number=1;x<tileCount;x++){
scope["tile_"+(x+1)].removeMovieClip();
}
}
}