# Dynamic Background Bitmap

**URL:** <https://forum.kirupa.com/t/dynamic-background-bitmap/179854>\
**Category:** flash\
**Created:** [February 23, 2006, 1:55pm UTC](https://forum.kirupa.com/t/dynamic-background-bitmap/179854 "2006-02-23T13:55:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grimshaw](https://avatars.discourse-cdn.com/v4/letter/g/439d5e/32.png) [@Grimshaw](https://forum.kirupa.com/u/Grimshaw)\
**Post date:** [February 23, 2006, 1:55pm UTC](https://forum.kirupa.com/t/dynamic-background-bitmap/179854/1 "2006-02-23T13:55:45Z")

</div>

I got the following code from [gotoandlearn.com](http://gotoandlearn.com) and found it very useful. How would you make this code work with loading the jpg in externally rather than importing it every time and giving it a linkage identifier in the library?

```auto

import flash.display.BitmapData;

cover._x = Stage.width / 2;
cover._y = Stage.height / 2;

var tile:BitmapData = BitmapData.loadBitmap("tile");

function fillBG() {
    this.beginBitmapFill(tile);
    this.moveTo(0,0);
    this.lineTo(Stage.width,0);
    this.lineTo(Stage.width,Stage.height);
    this.lineTo(0,Stage.height);
    this.lineTo(0,0);
    this.endFill();
}

fillBG();

var stageL:Object = new Object();
stageL.onResize = function() {
    fillBG();
    cover._x = Stage.width / 2;
    cover._y = Stage.height / 2;
}

Stage.addListener(stageL);

```
