# loadBitmapSmoothed image tracing 0 width and 0 height

**URL:** <https://forum.kirupa.com/t/loadbitmapsmoothed-image-tracing-0-width-and-0-height/253298>\
**Category:** flash\
**Created:** [February 28, 2008, 10:34pm UTC](https://forum.kirupa.com/t/loadbitmapsmoothed-image-tracing-0-width-and-0-height/253298 "2008-02-28T22:34:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixel\_streamer](https://avatars.discourse-cdn.com/v4/letter/p/a8b319/32.png) [@pixel\_streamer](https://forum.kirupa.com/u/pixel_streamer)\
**Post date:** [February 28, 2008, 10:34pm UTC](https://forum.kirupa.com/t/loadbitmapsmoothed-image-tracing-0-width-and-0-height/253298/1 "2008-02-28T22:34:13Z")

</div>

The code I found below basically caches an image and renders it to the screen with controls for keeping the loaded image smooth.

My problem is the image I tried isn’t registering a width or height, thought the clip is visible, and no errors were given

Can someone tell me why the code below doesn’t effectively center the smiley.png image?

Thanks

```auto

// from http://www.kaourantin.net/2005/12/dynamically-loading-bitmaps-with.html
import flash.display.*;

SW = Stage.width;
SH = Stage.height;
function loadBitmapSmoothed(url:String, target:MovieClip) {
    // Create a movie clip which will contain our 
    // unsmoothed bitmap
    var bmpMC:MovieClip = target.createEmptyMovieClip("bmpMC", target.getNextHighestDepth());
    // Create a listener which will notify us when 
    // the bitmap loaded successfully
    var listener:Object = new Object();
    // Track the target
    listener.tmc = target;
    // If the bitmap loaded successfully we redraw the 
    // movie into a BitmapData object and then attach 
    // that BitmapData to the target movie clip with 
    // the smoothing flag turned on.
    listener.onLoadInit = function(mc:MovieClip) {
        mc._visible = false;
        var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true, 0x44FFFFFF);
        this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);
        bitmap.draw(mc);
        mc.removeMovieClip(this);
    };
    // Do it, load the bitmap now
    var loader:MovieClipLoader = new MovieClipLoader();
    loader.addListener(listener);
    loader.loadClip(url, bmpMC);
}
this.createEmptyMovieClip("myMC", this.getNextHighestDepth());
this.loadBitmapSmoothed("images/smiley.png", myMC);
myMC._x=(SW/2)-(myMC._width/2);
myMC._y=(SH/2)-(myMC._height/2);
trace("myMC._x:	" + myMC._x);
trace("myMC._y:	" + myMC._y);
trace("myMC._width:	" + myMC._width);
trace("myMC._height:	" + myMC._height);
trace (this);

```
