A* PathFinder for Flash

Use the A* algorithm to create a path finder for your flash games.
The A* can be summarized as:

    setup the openlist (an array)
    setup the closedlist (an array)
    push the starting node to the open list (node is a square in our grid)
    while the openlist is not empty
        Look for the lowest 'f' cost node on the open list and pop from the openlist and name it 'current'
        if the current node is the goal then we found the solution, exit the while loop
        for each of the node adjacent to the current node (8 is we allow diagonal movement)
        set the parent of this adjacent to 'current'
                if a node with the same position as the adjacent node is in the open list /
                and its 'f' is lower than the node adjacent
                        then skip current adjacent node
                if a node with the same position is in closedlist /
                and its 'f' is lower
                        then skip current adjacent node
                otherwise push the current node to the open list
                remove occurences of adjacent node from OPEN and CLOSED list
                Add adjacent node to the OPEN list
        end for
        add the current node to the closed list
    end while

Read the article on my wiki
View the working example

Share with...