Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

On-stage Bitmap Instances in Flash Professional

Posted June 19, 2009 by senocular

It's not often I run across something I didn't know as simple as this. In fact I'm a little embarrassed that I didn't know this, but it gives me comfort that some other people I talked to also didn't know.

What is this of which I speak? Well it may or may not be fairly common knowledge that normally, when you place a bitmap from your library onto the workarea (a.k.a. "the stage" though technically, it's never really the stage, at least not the same stage ActionScript refers to) in the Flash Professional authoring tool, that bitmap becomes a shape, or a part of a shape consisting of other bitmap or vector graphics within the same layer or z-ordering group, once you publish your SWF. A quick test will reveal this behavior:
  1. Create a new Fla
  2. File > Import > Import to Stage...
  3. Add the following frame script:
    trace(getChildAt(0));
  4. Test movie

Result?
[object Shape]

If you didn't already know that, that's interesting enough. How then, you may ask, do you get an actual Bitmap instance on the stage in Flash? Until yesterday, I thought you couldn't except through ActionScript. But it turns out that is not true. Bitmap objects on the stage will become Bitmap instances rather than shapes if that bitmap image is exported for ActionScript (via library item properties).
Edit the image imported in the above example to be exported for ActionScript and run again to get the following:
[object Bitmap]

In other words, that image on the timeline has become a true bitmap instance rather than part of a shape. The Flash GUI still doesn't give you options for things like instance names or anything at this point, but the object available in the display list is in fact a true Bitmap.