Flash as drawing operation: Random cut bitmap experiment
Source: Internet
Author: User
Original: Ybzjllj.
Effect: Use the mouse to draw a random shape, drag the shape, from the original artwork cut out the plot area of the plot.
Note: Non-masking, feel better than mask simple.
Used: As drawing, Bitmap object, bitmap fill. Import Flash.display.BitmapData;
Import Flash.geom.Matrix;
Import a picture, put on the stage, become MC, instance named "original"
"MC" is used to draw inside.
var artwork: MovieClip, Mc:movieclip;
var draw line = false;//Draw Line Flag
var bmpimage:bitmapdata=new BitmapData (original image. _width, original image. _height);//Create Bitmap Object
Bmpimage.draw (original image, New Matrix ())////Map bitmap objects with "artwork"
When the mouse is pressed
Original artwork. Onpress = function () {
if (Mc.hittest (_xmouse, _ymouse, True)) {
Mc.startdrag (); If the mouse is on the MC, start dragging it
} else {
When the mouse is pressed, the mouse is not copied on the MC, start drawing Line
Draw line = true;
MC = This.createemptymovieclip ("MC", 1);//Create an empty MC, this action will also delete the original painted diagram, if you do not want to delete the original, use the array instead.
Mc.linestyle (1, 0xff0000); Line Style
Mc.beginbitmapfill (Bmpimage,new Matrix (), false); Identity Bitmap Fill Start
Mc.moveto (_xmouse-this._x, _ymouse-this._y); Move the drawing line from the beginning to this
}
};
Original artwork. OnMouseUp = function () {
if (draw line) {
Draw line = false;
Mc.endfill (); Fill End
} else {
Mc.stopdrag ();
}
};
Original artwork. OnMouseMove = function () {
if (draw line) {
Mc.lineto (_xmouse-this._x, _ymouse-this._y); If the drawing line status is true, move the mouse to draw a line
}
};
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.