View comments | RSS feed

floodFill (BitmapData.floodFill method)

public floodFill(x:Number, y:Number, color:Number) : Void

Performs a flood fill operation on an image starting at an (x, y) coordinate and filling with a certain color. The floodFill() method is similar to the paint bucket tool in various painting programs. The color is an ARGB color that contains alpha information and color information.

Availability: ActionScript 1.0; Flash Player 8

Parameters

x:Number - The x coordinate of the image.

y:Number - The y coordinate of the image.

color:Number - The ARGB color to use as a fill. ARGB colors are often specified in hexadecimal format, like 0xFF336699.

Example

The following example shows how to apply a flood fill a color into to an image starting at the point where a user clicks the mouse within a BitmapData object.

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

var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());

myBitmapData.fillRect(new Rectangle(0, 0, 50, 40), 0x00FF0000);

mc.onPress = function() {
    myBitmapData.floodFill(_xmouse, _ymouse, 0x000000FF);
}

Version 8

Comments


No screen name said on Sep 18, 2005 at 10:43 AM :
Will currently take RGB values, see no difference in ARGB.
Ɓukasz Grela said on Nov 5, 2005 at 4:08 PM :
great function, but shouldn't has a tolerance parameter? It would be great advantage of this function

 

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/00001952.html