Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > BitmapData (flash.display.BitmapData) > draw (BitmapData.draw method) | |||
public draw(source:Object, [matrix:Matrix], [colorTransform:ColorTransform], [blendMode:Object], [clipRect:Rectangle], [smooth:Boolean]) : Void
Draws a source image or movie clip onto a destination image, using the Flash Player vector renderer. You can use Matrix, ColorTransform, BlendMode objects, and a destination Rectangle object to control how the rendering performs. Optionally, you can specify whether the bitmap should be smoothed when scaled. This works only if the source object is a BitmapData object.
This method directly corresponds to how objects are drawn using the standard vector renderer for objects in the authoring tool interface.
A source MovieClip object does not use any of its on-stage transformations for this call. It is treated as it exists in the library or file, with no matrix transform, no color transform, and no blend mode. If you want to draw the movie clip by using its own transform properties, you can use its Transform object to pass the various transformation properties.
Availability: ActionScript 1.0; Flash Player 8
source:Object - The BitmapData object to draw.
matrix:flash.geom.Matrix [optional] - A Matrix object used to scale, rotate, or translate the coordinates of the bitmap. If no object is supplied, the bitmap image will not be transformed. Set this parameter to an identity matrix, created using the default new Matrix() constructor, if you must pass this parameter but you do not want to transform the image.
colorTransform:flash.geom.ColorTransform [optional] - A ColorTransform object that you use to adjust the color values of the bitmap. If no object is supplied, the bitmap image's colors will not be transformed. Set this parameter to a ColorTransform object created using the default new ColorTransform() constructor, if you must pass this parameter but you do not want to transform the image.
blendMode:Object [optional] - A BlendMode object.
clipRect:flash.geom.Rectangle [optional] - A Rectangle object. If you do not supply this value, no clipping occurs.
smooth:Boolean [optional] - A Boolean value that determines whether a BitmapData object is smoothed when scaled. The default value is false.
The following example shows how to draw from a source MovieClip instance to a BitmapData object.
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_1.attachBitmap(myBitmapData, this.getNextHighestDepth());
var mc_2:MovieClip = createRectangle(50, 40, 0xFF0000);
mc_2._x = 101;
var myMatrix:Matrix = new Matrix();
myMatrix.rotate(Math.PI/2);
var translateMatrix:Matrix = new Matrix();
translateMatrix.translate(70, 15);
myMatrix.concat(translateMatrix);
var myColorTransform:ColorTransform = new ColorTransform(0, 0, 1, 1, 0, 0, 255, 0);
var blendMode:String = "normal";
var myRectangle:Rectangle = new Rectangle(0, 0, 100, 80);
var smooth:Boolean = true;
mc_1.onPress = function() {
myBitmapData.draw(mc_2, myMatrix, myColorTransform, blendMode, myRectangle, smooth);
}
function createRectangle(width:Number, height:Number, color:Number):MovieClip {
var depth:Number = this.getNextHighestDepth();
var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
Version 8
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00001950.html
Comments
Charles Parcell said on Sep 30, 2005 at 11:08 AM : No screen name said on Oct 12, 2005 at 9:06 AM : Mister Neb said on Nov 3, 2005 at 2:10 PM : No screen name said on Nov 15, 2005 at 2:10 PM : No screen name said on Nov 21, 2005 at 5:54 AM : HedgePedge said on Dec 3, 2005 at 11:46 PM : BukuMartian said on Dec 21, 2005 at 8:24 PM : FredzCode said on Feb 7, 2006 at 1:20 AM : occhio said on Jun 22, 2006 at 2:35 AM : johnnystorm0 said on Nov 9, 2006 at 7:26 AM : No screen name said on Jan 23, 2007 at 4:35 PM : KNovak23 said on Jan 31, 2007 at 3:14 PM : 303dreams said on Feb 27, 2007 at 8:51 PM : fillcell Gerra said on May 14, 2007 at 2:20 PM : dr deetee said on May 30, 2007 at 6:25 PM :