我正在尝试将影片剪辑绘制到位图数据并让它看起来就像我刚刚将影片剪辑直接添加到舞台一样。然而结果发生了变化。我怀疑它与原点和边界有关,但无法弄清楚。
http://megaswf.com/s/2441986 (右边那个是问题)
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.geom.Rectangle;
public class Main extends Sprite
{
public var movieClip:MovieClip;
public var bitmapData:BitmapData
public var bitmap:Bitmap;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(Event.ENTER_FRAME, update);
// for comparison, this is what I want the result to look like
movieClip = new skeletonWalk();
movieClip.x = 200;
movieClip.y = 200;
addChild(movieClip);
// and this it the problem child
bitmap = new Bitmap();
bitmap.x = 300;
bitmap.y = 200;
addChild(bitmap);
}
private function update(e:Event):void
{
var bounds:Rectangle = movieClip.getBounds(movieClip);
bitmapData = new BitmapData(bounds.width, bounds.height, true, 0x0);
bitmapData.draw(movieClip, new Matrix(1, 0, 0, 1, -bounds.x, -bounds.y));
bitmap.bitmapData = bitmapData;
}
}
}