ok i got it to work, but i still have one glitch, on loading the the image it doesn’t go fullscreen straight away it delays for 1-2-sec or so, Why???
/////////////////////
// load background //
/////////////////////
bgpreload = 1;
var bgx = new XML();
bgx.ignoreWhite = true;
bgx.load("content/xml/backgrounds.xml");
bgx.onLoad = function(success) {
dolzina = bgx.firstChild.childNodes.length;
i = Math.floor(Math.random()*dolzina);
bg.loadMovie(this.firstChild.childNodes*.childNodes[0].attributes.picx);
};
//
transfer = function () {
image = new flash.display.BitmapData(bg._width, bg._height);
image.draw(bg);
bg1.attachBitmap(image, 1, true, true);
// set size and position on load
if (Stage.height/Stage.width>bg1._height/bg1._width) {
img_prop = bg1._width/bg1._height;
bg1._height = Stage.height;
bg1._width = Stage.height*img_prop;
bg1._y = (Stage.height/2)-(bg1._height/2);
bg1._x = (Stage.width/2)-(bg1._width/2);
} else {
img_prop = bg1._height/bg1._width;
bg1._width = Stage.width;
bg1._height = Stage.width*img_prop;
bg1._y = (Stage.height/2)-(bg1._height/2);
bg1._x = (Stage.width/2)-(bg1._width/2);
}
unloadMovie(bg);
};
p2.txtx.txtx.txtx.text = "LOADING RANDOM BACKGROUND";
//
var stage_listener:Object = new Object();
stage_listener.onResize = function():Void {
// re-size & re-position image on movement
if (Stage.height/Stage.width>bg1._height/bg1._width) {
img_prop = bg1._width/bg1._height;
bg1._height = Stage.height;
bg1._width = Stage.height*img_prop;
bg1._y = (Stage.height/2)-(bg1._height/2);
bg1._x = (Stage.width/2)-(bg1._width/2);
} else {
img_prop = bg1._height/bg1._width;
bg1._width = Stage.width;
bg1._height = Stage.width*img_prop;
bg1._y = (Stage.height/2)-(bg1._height/2);
bg1._x = (Stage.width/2)-(bg1._width/2);
}
};
Stage.addListener(stage_listener);