Dynamic Background (Center on 800x600 or Strech if Bigger)

Greetings,

I´m trying to create a Dynamic Background that “Fit” on the screen resolution doing the follow.:

If the resolution is smaller than 800x600, the background image will be centered on the screen, and if the resolution is bigger than 800x600 the background image will “strech” to fit the resolution (without deform the background image).

The Script Works Ok but sometimes a White (Background FLA color) Area appears, this means that the Script have some error or are not well finished…

Can anyone give me a hand to fix this ? and make the background always fit on the screen, without that little bug. ?


Stage.showMenu = false;
Stage.scaleMode = "noScale";
Stage.align = "LT";

background.onResize = function() {
   
    if (Stage.width > 800 || Stage.height > 600){

        var _l2 = this._width/this._height;
        var _l3 = Stage.width/Stage.height;
   
        if (_l3>=_l2) {
            this._width = Stage.width;
            this._height = Stage.width/_l2;
            background._x = Stage.width / 2;
            background._y = Stage.height / 2;
           
        }else{

        if (_13<_12){
            this._height = Stage.height;
            this._width = Stage.height*_l2;
            background._x = Stage.width / 2;
            background._y = Stage.height / 2;
   
        }};
       
    }else{

        background._x = Stage.width / 2;
        background._y = Stage.height / 2;
       
}};



Stage.addListener(background);


Ps.: To test the code just paste the Action on the first frame and then create a movie clip with a 800x600 image and name the instance as “background”.