Just explain a little more...

subPicture.copyPixels(picture,new Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height-borderSize*2),new Point(borderSize,borderSize));

It's mean:

-subPicture is the BitmapData where you want to copy the pixels
-copyPixels is a method of BitmapData object
-picture is the BitmapData witch is the source of pixels
-new Rectangle is a flash.geom.Rectangle object, witch define the top left point of the part of the source picture (inside the BitmapData here called picture) you want to copy, and the width and the height of this rectangle -new Point is a flash.geom.Point object witch define the top left point inside the destination BitmapData where you want to copy your pixels (usually (0,0) but you can choose something else)

David Buff

----- Original Message ----- From: "David Buff" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, October 19, 2006 11:05 AM
Subject: Re: [Flashcoders] attachbitmap and copy pixels.


Hi,

Just create a fla and import a picture (jpg) in the librairy (minimum 150,150). Link this picture with the id: picture_id
Then try this code.

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

var picture:BitmapData = BitmapData.loadBitmap("picture_id");
_root.createEmptyMovieClip("pictureMc",1);
pictureMc.attachBitmap(picture,1);

var subPicture:BitmapData = new BitmapData(100,100,false,0xFF0000);
_root.createEmptyMovieClip("subPictureMc",2);
subPictureMc.attachBitmap(subPicture,1);

var xPos:Number = 50;
var yPos:Number = 50;
var borderSize:Number = 10;

subPictureMc.onRelease = function() {
subPicture.copyPixels(picture,new Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height-borderSize*2),new Point(borderSize,borderSize));
}

Your picture must be displayed. A red box will appear on it. Then click on the red box, a part of your picture is drawed into the red box. Change the xPos, yPos and borderSize. You'll be abble to anderstand copyPixels with this exemple.

(but it don't show how to use the alpha channel... another time, when you'll be familiar with this)

enjoy,

David Buff

----- Original Message ----- From: "Johnny Zen" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, October 19, 2006 10:40 AM
Subject: [Flashcoders] attachbitmap and copy pixels.


Hi all

Can anyone give me a super simple example on using copypixels to take
a "snapshot" of a jpg within a movie clip. I'm having trouble
understanding the examples of bitmapdata and copypixels.

It would be a great help for me.


Best wishes


Johnny
_______________________________________________
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


_______________________________________________
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


_______________________________________________
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