movieclip 将它发送到另一个帧

movieclip sending it to another frame

iv 制作了一个着色游戏,我想制作它以便您可以保存绘图(一个 Movieclip)并将其发送到另一个帧或场景,iv 一直在研究它是如何实现的并且看起来它可以完成位图数据,但我什至不知道如何去做。

您需要为保存按钮命名,并为其添加点击监听器。

// create the BitmapData that you'll be drawing to, give it the same dimensions 
var savedImage:BitmapData = new BitmapData(holder.width, holder.height, false, 0xFFFFFF);

// add a click listener to your save button
saveBtn.addEventListener(MouseEvent.CLICK, onSave);
function onSave(event:MouseEvent):void 
{
    // need to apply a transformation matrix because holder's origin is centered
    var matrix:Matrix = new Matrix();
    matrix.translate(holder.width * .5, holder.height * .5);

    // clear out any existing image on savedImage
    savedImage.fillRect(savedImage.rect, 0xFFFFFF);

    // draw the holder onto the savedImage bitmapdata, using the transform matrix
    savedImage.draw(holder, matrix, null, null, null, true);
}

从那时起,您可以将 savedImage BitmapData 传递给 Bitmap 实例:

var savedBitmap:Bitmap = new Bitmap(savedImage);

只要savedBitmap在正确的范围内,您就可以将其添加到另一帧的显示列表中:

addChild(savedBitmap);