# Embedding an image works only for a few times, then I need to resize

**URL:** <https://forum.kirupa.com/t/embedding-an-image-works-only-for-a-few-times-then-i-need-to-resize/320432>\
**Category:** Uncategorized\
**Created:** [March 23, 2011, 10:26am UTC](https://forum.kirupa.com/t/embedding-an-image-works-only-for-a-few-times-then-i-need-to-resize/320432 "2011-03-23T10:26:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wentu](https://avatars.discourse-cdn.com/v4/letter/w/ad7895/32.png) [@Wentu](https://forum.kirupa.com/u/Wentu)\
**Post date:** [March 23, 2011, 10:26am UTC](https://forum.kirupa.com/t/embedding-an-image-works-only-for-a-few-times-then-i-need-to-resize/320432/1 "2011-03-23T10:26:12Z")

</div>

Hi all

I am trying to use an image and I am having the following problem:

- the image is a png, 2000x2464 pixels
- I embed the image
- Everything works OK during the first few tries
- After some debugging session, without changing anything in the image embedding, the image isn’t loaded anymore, or better, it seems loaded ( in the variables I see the istance of my class and it is not null) but the bitmapdata of the image is null, width and height are 0.
- Now, I resize the image to something smaller and i start again. Everything works fine again and the cycle begins again !

Here’s the code:  
In the declarations of the class containing the image:

```auto
        [Embed(source = "images/italyMapZOUT.png")]
        [Bindable]
        var mapClass:Class;
        var map:Bitmap;

```

In the initialization method that i call after construction:

```auto
        map = new mapClass();
        var bdata:BitmapData = map.bitmapData;
        var myRatio:Number = someNumber / map.width;
        ...
        

```

It seems to me that I am embedding the image as described in zillions of sites and it is actually working… for some times ! Then , after say 5 or 6 debugging sessions, I get an error evaluating “someNumber” because width is zero, and checking the local variable I see that bitmapData is null.  
Resizing to a smaller image , saving said image and restarting solves the issue temporarily.  
Any idea what’s happening ?

Thank you very much !  
Wentu
