bitmapData's dimensions (width and height)

994 Views Asked by At

I'm new to flex and I have a question concerning bitmapData and its width and height.

Normally you set up bitmapData like this in AS3:

var bd:BitmapData = new BitmapData(100, 100, true, 0x00000000);
var bm:Bitmap = new Bitmap(bd);

But in Flex embedding an an image works like this:

[Embed(source="../../../../../assets/sprites/asteroids/asteroid_32_full.gif")]
public static const Asteroid1:Class;
var imageBM:Bitmap = new Library.Asteroid1();

When using the bitmapData (e.g. imageBM.bitmapData) I don't have to set up width and height any more. Does the Flash player know the width and height of a bitmapData automatically even when NOT setting up the bitmapData's width and height? I'm totally unaware about this topic because I don't know whether the Flash player always knows the dimensions of a bitmapData. Could this cause problems when not setting up the dimensions of a bitmapData?

1

There are 1 best solutions below

3
On BEST ANSWER

If you're generating a BitmapData object from scratch, you have to set the width and height.

If it's being generated automatically via image import, you don't. It's set under the covers by the image import process.