/ Published in: ActionScript 3
Manual Rasterize
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//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 : var apple:Apple; for (var i:int = 0; i< 100; i++) { apple = new Apple(); apple.cacheAsBitmap = true; addChild ( apple ); } //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 : var source:AppleSource = new AppleSource(); var buffer:BitmapData = new BitmapData ( source.width, source.height, true ); buffer.draw ( source ); var bitmapApple:BitmapApple; for (var i:int = 0; i< 100; i++ ) { bitmapApple = new BitmapApple( buffer ); addChild ( bitmapApple ); }