Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > BitmapData (flash.display.BitmapData) > pixelDissolve (BitmapData.pixelDissolve method) | |||
public pixelDissolve(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, [randomSeed:Number], [numberOfPixels:Number], [fillColor:Number]) : Number
Performs a pixel dissolve either from a source image to a destination image or by using the same image. Flash Player uses a randomSeed value to generate a random pixel dissolve. The return value of the function must be passed in on subsequent calls to continue the pixel dissolve until it is finished.
If the source image does not equal the destination image, pixels are copied from the source to the destination using all of the properties. This allows dissolving from a blank image into a fully populated image.
If the source and destination images are equal, pixels are filled with the color parameter. This allows dissolving away from a fully populated image. In this mode, the destination point parameter is ignored.
Availability: ActionScript 1.0; Flash Player 8
sourceBitmap:flash.display.BitmapData - The input bitmap image to use. The source image can be a different BitmapData object or it can refer to the current BitmapData instance.
sourceRect:flash.geom.Rectangle - A rectangle that defines the area of the source image to use as input.
destPoint:flash.geom.Point - The point within the destination image (the current BitmapData instance) that corresponds to the upper-left corner of the source rectangle.
randomSeed:Number [optional] - The random seed to use to start the pixel dissolve. The default value is 0.
numberOfPixels:Number [optional] - The default is 1/30 of the source area (width x height).
fillColor:Number [optional] - An ARGB color value that you use to fill pixels whose source value equals its destination value. The default value is 0.
Number - The new random seed value to use for subsequent calls.
The following example uses pixelDissolve() to convert a grey BitmapData object to a red one by dissolving 40 pixels at a time until all 8000 pixels have changed colors:
import flash.display.BitmapData;
import flash.geom.Point;
var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
mc.onPress = function() {
var randomNum:Number = Math.floor(Math.random() * 10);
dissolve(randomNum);
}
var intervalId:Number;
var totalDissolved:Number = 0;
var totalPixels:Number = 8000;
function dissolve(randomNum:Number) {
var newNum:Number = myBitmapData.pixelDissolve(myBitmapData, myBitmapData.rectangle, new Point(0, 0), randomNum, 40, 0x00FF0000);
clearInterval(intervalId);
if(totalDissolved < totalPixels) {
intervalId = setInterval(dissolve, 10, newNum);
}
totalDissolved += 40;
}
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/00001964.html
Comments
No screen name said on Nov 7, 2006 at 11:41 AM :