Yes, you can copy only the visible pixels of a bitmap.

To do this, you must pass the optional AlphaBitmap parameter for copyPixels:

public copyPixels(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, [alphaBitmap:BitmapData], [alphaPoint:Point], [mergeAlpha:Boolean]) : Void

piece_bd.copyPixels(piece_mc,new
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height- borderSize*2),new
Point(borderSize,borderSize), ALPHA BITMAP);

I'm not sure what's going on in your code, so I can't say what should be the ALPHA BITMAP, piece_mc?

If you do that, the copied parts of piece_mc would be basically "self- masked."


On Oct 19, 2006, at 8:01 AM, flashcoders- [EMAIL PROTECTED] wrote:

Thanks the help everyone.

Ok i'm slowly getting my head around this bitdata.

If I wanted to mask a bg pic using setmask.

Can i then copy the visible area using copypixels? and use this a
fixed image ("snapshot") ? Seem to be stuck a little

here is my code as far:-

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

//create blank movieclip, create bd object. put pic into bd object,
then put object into movieclip.
var picture:BitmapData = BitmapData.loadBitmap("rawbg");
_root.createEmptyMovieClip("pictureMc",this.getNextHighestDepth());
pictureMc.attachBitmap(picture,1);
///

//create blank mc, attach piecepic to mc.
piece_mc = this.createEmptyMovieClip("orig", this.getNextHighestDepth());
piece_mc.attachMovie("piece0",piece0,this.getNextHighestDepth());
//
// create bd for peice. draw the piece into the bd object.
piece_bd = new BitmapData (this.piece_mc.width, this.piece_mc.height, true);
                piece_bd.draw (this.piece_mc, this.matrix);

//apply mask
pictureMc.setMask(_root.piece_mc)

//HELP HERE - I dont understand this section, althougj think i'm on
the right lines.
piece_bd.copyPixels(piece_mc,new
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height- borderSize*2),new
Point(borderSize,borderSize));


//drag the fixed snapshot piece around
piece_mc.onRelease = function() {

 this.startDrag();
}

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to