With the introduction of flash 8 we had the ability to manipulate bitmaps with filters. Flash player 9 optimises the calculations of these filters and flash player 10 promises to preform these calculations on the clients graphics hardware. I believe that there are many non-graphic applications of these technologies such as path finding.
In the example below I have investigated using a simple convolution filter to expand the area of colour by one pixel. Repetitively applying this filter allowed me to fill a maze like pouring a can of paint in a mouse maze. Once the destination is reached it is a simple process to back track and evaluate the route taken. This route will be the fastest possible.
var myBitmapData:BitmapData = new BitmapData(200,200, false, 0xFFCCCCCC);
var myBitmap:Bitmap = new Bitmap(myBitmapData,”auto”,false);
var maze:Sprite = new Sprite();
var size:Number = 10;
var offSet:Number = Math.floor(size/2);
function startDraw(event:MouseEvent):void {
maze.addEventListener(MouseEvent.MOUSE_MOVE, drawPoint);
}
function endDraw(event:MouseEvent):void {
maze.removeEventListener(MouseEvent.MOUSE_MOVE, drawPoint);
}
function drawPoint(event:MouseEvent):void {
var rect:Rectangle = new Rectangle(maze.mouseX-offSet, maze.mouseY-offSet,size,size)
myBitmapData.fillRect(rect,0xFF0000FF);
}