The flood-fill algorithm is used to determine the area connected to a given node in a multi-dimensional array. This algorithm is used in the game Clicken Gold to determine which is used to find out what blocks should be cleared. It is also used in paint programs for filling in contiguous areas.


Flood-Fill Algorithm To find the entire area you check the all of sides of the Node in no particular order. Then you continue checking recursively from that point. In the example on the left when Node 1 is checked the Nodes around it will be checked before continuing to Node 2.


I implemented the Flood-Fill algorithm in Flash ActionScript. I created a class called Node that handles the drawing and coloring of the Node. I implemented the Algorithm with animation so you can see how the algorithm executes.

Click on any of the colored areas to fill them with red using the Flood-Fill algorithm.



Download the Flood-Fill Algorithm Flash Source

Date posted: June 3, 2006 | Author: | 1 Comment »

Categories: Programming

Tags: , , , ,

One Response to Flood-Fill Algorithm in Flash ActionScript

  1. Google says:

    Hey There. I found your blog using msn. This is a really
    well written article. I’ll make sure to bookmark it
    and return to read more of your useful information. Thanks for
    the post. I will certainly return.

Leave a Reply to Google Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2013, Neil Bittner. All Rights Reserved.