Free ActionScript

Flash AS2 & AS3 Tutorials, Game Code, Effects, Source Files & Sample Downloads

Using BitmapData – Center Bitmap Inside MovieClip

5 Comments »

Here is a simple Flash BitmapData class example; How to attach bitmaps and center them inside their holder container movieclip.

Using bitmap images instead of vector shapes is a great way to increase performance in your flash games.

Preview

Download Fla Sample

Download Fla Sample

5 Responses

nice, it is usefull for flash websites too!

  • No way to clear the bitmaps?

  • GeorgeC,

    Since bitmaps are being attached directly to _root, you could loop thru all objects on _root and remove them.

    Another way is to add all new bitmaps to an array. Once you want them all removed, you could loop thru that array and remove them.

    PR

  • Thanks.
    OK, I have fixed that problem. However I have a new one. Because the bitmap’s depth is highest on _root I cannot put an MC above the bitmap. I am using this for a blood splat effect where the player is above the blood but I’m finding it really difficult. And when I swap depths with mc and mc(nested?:bitmap) it only works for the first bitmap not all of them.

    btw it’s a mixture of this and the multiple enemies code, with my edits. Thanks you so much for these.

  • GeorgeC,

    I would approach your problem a little differently.

    Instead of putting all your objects (player, enemies, blood splatter, bullet holes) in to one container, I would split these up.

    Create a container for each one of these (and perhaps an array per container that holds all these objects):

    Sky (clouds, smoke, etc)
    Player (you want the player to always be on top)
    Enemies
    Effects (blood, bullet holes)
    Ground

    Hope this helps. :smile:
    PR

  • Leave a Reply

    You must be logged in to post a comment.