2012-11-21 3 views
2

여기에 약간의 고심을하는 코더가 아닙니다 :AS3 bitmapData on nextframe();

다음 프레임에 현재 프레임을 CPU 효율을 위해 비트 맵으로 그려 봅니다. AS2에서이 코드는 매력처럼 작동합니다.

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); 

AS3에서이를 다시 작성하는 방법을 알아야합니다. 고맙습니다!

+0

attachBitmap 행을 다음과 같이 바꿔야합니다 :'addChild (new Bitmap (tBitmapData));' –

답변

1

먼저 AS3에서 BitmapData은 DisplayObject가 아닙니다. Bitmap 개체로 포장해야합니다. 조지 Profenza가 언급 한 바와 같이 그럼 당신은하는 AddChild와 attachBitmap 대체 :

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)); 

또한 당신의 변수 (var tBitmapData:BitmapData)를 입력하려고합니다. 이렇게하면 성능이 향상되고 컴파일러에서 일부 오류를 포착 할 수 있습니다.