Manual Rasterize


/ Published in: ActionScript 3
Save to your folder(s)

Manual Rasterize


Copy this code and paste it in your HTML
  1. //Hopefully, you can bypass this limitation by creating a BitmapData by yourself, draw the MovieClip on it, and pass it to multipe Bitmap instances. So let's take a simple example, in the folllowing movie, when you click on the "cacheAsBitmap" button, I create multiple instances of an Apple MovieClip, set cacheAsBitmap, and move them on screen :
  2.  
  3. var apple:Apple;
  4.  
  5. for (var i:int = 0; i< 100; i++)
  6. {
  7. apple = new Apple();
  8.  
  9. apple.cacheAsBitmap = true;
  10.  
  11. addChild ( apple );
  12. }
  13. //When you click on the "draw" button, I first create an instance of the apple MovieClip, draw it on a BitmapData and then create Bitmap instances linked to the one and unique BitmapData instance :
  14.  
  15. var source:AppleSource = new AppleSource();
  16.  
  17. var buffer:BitmapData = new BitmapData ( source.width, source.height, true );
  18.  
  19. buffer.draw ( source );
  20.  
  21. var bitmapApple:BitmapApple;
  22.  
  23. for (var i:int = 0; i< 100; i++ )
  24. {
  25. bitmapApple = new BitmapApple( buffer );
  26.  
  27. addChild ( bitmapApple );
  28. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.