# Resizing Bitmap proportionally

**URL:** https://forum.kirupa.com/t/resizing-bitmap-proportionally/263162
**Category:** flash
**Created:** [June 13, 2008, 12:35am UTC](https://forum.kirupa.com/t/resizing-bitmap-proportionally/263162 "2008-06-13T00:35:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Jtbrack](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@Jtbrack](https://forum.kirupa.com/u/Jtbrack)
#### Post date: [June 13, 2008, 12:35am UTC](https://forum.kirupa.com/t/resizing-bitmap-proportionally/263162/1 "2008-06-13T00:35:02Z")

</div>

My goal at the moment is to simply add a bitmap to the display, and have it fit the entire screen width and resize it’s height proportionally… I have some coding done, but here’s where I’m stuck: Initially the bitmap does not display properly, but when using the same code in my resizeHandler() the image corrects itself and displays properly.

Here’s the code:

```auto
package {
    import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import flash.net.*;
    import br.com.stimuli.loading.*; 
    import caurina.transitions.*;
    import flash.net.URLRequest;
    
    public class Photography extends MovieClip {

        var loader : BulkLoader = new BulkLoader("main-site");
        //Photos
        var swings : Bitmap = new Bitmap;
        
        public function Photography() {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            this.stage.addEventListener(Event.RESIZE, resizeHandler);
            
            loader.add("images/swings.jpg", {id:"01"});
            loader.addEventListener(BulkLoader.COMPLETE, allLoaded);
            loader.start();
        }
        
        public function allLoaded(event:Event): void {
            swings = loader.getBitmap("01");
            swings.width = stage.stageWidth;
            swings.x = (stage.stageWidth / 2) - (swings.width / 2);
            swings.y = (stage.stageHeight / 2) - (swings.height / 2);
            var ratio : Number = swings.scaleX;
            swings.scaleY = ratio;
            addChild(swings);
        }
        
        public function resizeHandler(event:Event): void {
            swings.width = stage.stageWidth;
            swings.x = (stage.stageWidth / 2) - (swings.width / 2);
            swings.y = (stage.stageHeight / 2) - (swings.height / 2);
            var ratio : Number = swings.scaleX;
            swings.scaleY = ratio;
        }
    }
}

```

I’m hoping I’m missing something small and simple, and any help is appreciated!
