# Almost There... 1 little problem

**URL:** <https://forum.kirupa.com/t/almost-there-1-little-problem/233258>\
**Category:** flash\
**Created:** [July 22, 2007, 12:39am UTC](https://forum.kirupa.com/t/almost-there-1-little-problem/233258 "2007-07-22T00:39:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![james182](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@james182](https://forum.kirupa.com/u/james182)\
**Post date:** [July 22, 2007, 12:39am UTC](https://forum.kirupa.com/t/almost-there-1-little-problem/233258/1 "2007-07-22T00:39:38Z")

</div>

ok i got it to work, ![](http://forum.kirupa.com/uploads/kirupa/798/c985a958819d8917.gif) 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???

```php

///////////////////// 
// 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);  

```
