Reputation: 21
not a coder so struggling a little here:
Trying to draw current frame in the next frame as a bitmap for cpu efficiency. In AS2 this code works like a charm:
import flash.display.*;
// # create the bitmap
var tBitmapData = new BitmapData(400, 200, true, 0x00000000);
// # now draw this movieClip's content to the bitmap
tBitmapData.draw(this);
// # 2nd frame should be blank!
nextFrame();
// # now attach the bitmap you made to this movieclip
this.attachBitmap(tBitmapData, 1, "auto", true);
Just need to know how to re-write this for AS3. Thank you!
Upvotes: 2
Views: 312
Reputation: 10193
First, in AS3 BitmapData is not a DisplayObject. You need to wrap it into a Bitmap object. Then you replace attachBitmap with addChild as George Profenza mentioned:
import flash.display.*;
// # create the bitmap
var tBitmapData:BitmapData = new BitmapData(400, 200, true, 0x000000);
// # now draw this movieClip's content to the bitmap
tBitmapData.draw(this);
// # 2nd frame should be blank!
nextFrame();
// # now attach the bitmap you made to this movieclip
this.addChild(new Bitmap(tBitmapData));
Also try to type your variables (var tBitmapData:BitmapData
). This increases performance and allows the compiler to catch some errors.
Upvotes: 1