Posted By

orazal on 08/22/07


Tagged

actionscript bitmapData


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

n00ge
mattlohmann


replaceByBitmap


 / Published in: ActionScript
 

  1. /**
  2.  * Makes a bitmap copy of an image clip and
  3.  * rewrites it with the same name, depth, position.
  4.  *
  5.  * @param target The movie clip to replace.
  6.  * @param transparent Specifies whether the bitmap image supports per-pixel transparency.
  7.  * @param fillColor A 32-bit ARGB color value that you use to fill the bitmap image area.
  8.  */
  9. function replaceByBitmap(target:MovieClip, transparent:Boolean, fillColor:Number):Void {
  10. import flash.display.BitmapData;
  11. var ox:Number = target._x;
  12. var oy:Number = target._y;
  13. if(transparent && fillColor){
  14. var bm:BitmapData = new BitmapData(target._width, target._height, true, 0x00FFFFFF);
  15. }else{
  16. var bm:BitmapData = new BitmapData(target._width, target._height);
  17. }
  18. bm.draw(target);
  19. var copy_mc:MovieClip = target._parent.createEmptyMovieClip(target._name, target.getDepth());
  20. copy_mc.attachBitmap(bm, 0, "never", true);
  21. copy_mc._x = ox;
  22. copy_mc._y = oy;
  23. }

Report this snippet  

You need to login to post a comment.