# How to draw this rectangle and load something in the middle of it

**URL:** https://forum.kirupa.com/t/how-to-draw-this-rectangle-and-load-something-in-the-middle-of-it/261131
**Category:** Uncategorized
**Created:** [May 23, 2008, 1:38pm UTC](https://forum.kirupa.com/t/how-to-draw-this-rectangle-and-load-something-in-the-middle-of-it/261131 "2008-05-23T13:38:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ecptavares](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@ecptavares](https://forum.kirupa.com/u/ecptavares)
#### Post date: [May 23, 2008, 1:38pm UTC](https://forum.kirupa.com/t/how-to-draw-this-rectangle-and-load-something-in-the-middle-of-it/261131/1 "2008-05-23T13:38:20Z")

</div>

Hi!  
I am trying to make a web site (1024 x 768) and I want to make a rectangle that will fit part of the window and this rectangle has to have a dropshadow. I want to load an image centered inside this rectangle.

Look what I am doing so far and please tell me what is wrong with it.

```auto

package
{
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.net.URLRequest;
    
    public class FNR extends MovieClip
    {
        var imgLoader : Loader;
        var url : URLRequest;
        var BackMC : MovieClip = new MovieClip();
        
        public function FNR()
        {
            init();
        }
        
        private function init():void
        {
            drawBackGround();
            loadFlyer();
        }

        private function drawBackGround():void
        {
            BackMC.graphics.lineStyle(1, 0x000000, 1);
            BackMC.graphics.drawRect(0,0,550,400);
            BackMC.graphics.endFill();
            addChild(BackMC);
        }
        
        private function loadFlyer():void
        {
            imgLoader = new Loader();
            url = new URLRequest("flyer.jpg");
            
            imgLoader.x = 0;
            imgLoader.y = 0;
            imgLoader.load(url);
            imgLoader.contentLoaderInfo.addEventListener(Event.OPEN, onFlyerOPEN);
            imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onFlyerPROGRESS);
            imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onFlyerCOMPLETE);
            
            imgLoader.load(url);
            addChild(imgLoader);
        }
        
        private function onFlyerOPEN(event:Event):void
        {
            trace("opened");
        }
        
        private function onFlyerPROGRESS(event:ProgressEvent):void
        {
            trace("Loading...");
        }
        
        private function onFlyerCOMPLETE(event:Event):void
        {
            trace("Closed");
        }
    }
}

```

but the rectangle is not being drawn correctly and it is getting bigger than my resolution which is set to 1024x768.

What am I doing wrong?

I also need to put a dropshadow in this rectangle.

---

<div class="post-metadata">

### Author: ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)
#### Post date: [May 23, 2008, 2:30pm UTC](https://forum.kirupa.com/t/how-to-draw-this-rectangle-and-load-something-in-the-middle-of-it/261131/2 "2008-05-23T14:30:28Z")

</div>

Is ur stage set to NO\_SCALE?

---

<div class="post-metadata">

### Author: ![ecptavares](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@ecptavares](https://forum.kirupa.com/u/ecptavares)
#### Post date: [May 23, 2008, 2:37pm UTC](https://forum.kirupa.com/t/how-to-draw-this-rectangle-and-load-something-in-the-middle-of-it/261131/3 "2008-05-23T14:37:46Z")

</div>

No!

---

<div class="post-metadata">

### Author: ![johnlouis](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/johnlouis/32/568_2.png) [@johnlouis](https://forum.kirupa.com/u/johnlouis)
#### Post date: [May 23, 2008, 2:59pm UTC](https://forum.kirupa.com/t/how-to-draw-this-rectangle-and-load-something-in-the-middle-of-it/261131/4 "2008-05-23T14:59:03Z")

</div>

are you viewing it in a browser?  
coz if you are, and you are setting it to fill the whole window, the swf could be stretching.  
try adding  
stage.scaleMode = StageScaleMode.NO\_SCALE;  
in your init() function and  
import flash.display.StageScaleMode;

---

<div class="post-metadata">

### Author: ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)
#### Post date: [May 24, 2008, 10:17am UTC](https://forum.kirupa.com/t/how-to-draw-this-rectangle-and-load-something-in-the-middle-of-it/261131/5 "2008-05-24T10:17:35Z")

</div>

```auto
			stage.align=StageAlign.TOP_LEFT;

```
