开发者

AS3 bitmapdata not updated

In my class I have created a Bitmap with a corresponding BitmapData object:

Class Members

private var _bitmapData:BitmapData;
private var _bitmap:Bitmap;
private var _history:Array;

Constructor:

_history = new Array();
_bitmapData = new BitmapData(50, 50, true, 0x00FFFFFF);
_bitmap = new Bitmap(_bitmapData);
this.addChild(_bitmap);

In my "modifyImage" function I want to modify the _bitmapData. However, this does not work unless I include the out commented lines:

//removeChild(this._b开发者_运维百科itmap);
_history.push(_bitmapData.clone());
_bitmapData.draw(item); // "item" passed by value
//this.addChild(_bitmap);

To revert changes I use the following (again, I have to remove and add the _bitmap to the stage):

//removeChild(this._bitmap);
_bitmapData = _history.pop();
_bitmap = new Bitmap(_bitmapData); // [EDIT]: out-commented this by mistake
//this.addChild(_bitmap);

Is their a workaround of removing and adding the _bitmap over and over again?

Help is highly appreciated. Thanks in advance!


you just need to set the bitmapData on the Bitmap. eg:

_bitmapData = _history.pop();  
_bitmap.bitmapData = _bitmapData;

Hope that helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜