Fill color with line boundaries

What i need is the ability to “fill” an area of “color” in an imported image onto the stage to whatever color i need, and for it to fill the entire area until it reaches a boundary.

Now, if your as lost reading that as i was when i typed it, what i need is exactly what you have in mspaint (Microsoft Paint) basically i need my own paint bucket tool, so that i can fill an area of an imported image to whatever color i want.

I have played around with the BitmapData.threshold function, however whilst it works, if a user colors area1 blue, and then area 3 blue, then decides he really wants area 3 red, when he repaints area3 red, he will also paint area1 red too…

Threshold just works too well, i need to re-painting or “filling” to stop when it hits a border, and not change other parts of the image that are the same color.

An example of the image is located here: http://www.xavierit.com.au/lineDrawing.JPG i want the user to be able to paint individual cells any color they want, but i cannot find an approprate way of doing this.:m2: