Author Archive for Dauntless

Updated to v1.3.1

There was a bug in basic2d.Map that would cause the wrong tiles to be used which could result in a wrong path. This has been fixed in v1.3.1

I also forgot to make a blog post about v1.3. I realeased it a few months ago and it’s a pretty major upgrade from v1.2 so be sure to check it out. You can find more details about the new features on the download page and in the comments.


Looks like my little A* doesn’t always generate the shortest path if you are able to walk diagonally. (If your characters can only walk vertically/horizontally, you’re safe from potentially walking a few extra tiles!)

I’m using the Manhattan heuristic which is good if you can only move horizontal or vertical, but it’s double as large as what you would expect it to be if you can move diagonally. That means that sometimes, a shorter path will not be looked at, because the algorithm guesses that it would be a worse path than the current one.

The good news: it’s an easy fix. If by the time you are reading this v1.3 isn’t out yet:

In, change the setH method:

public function setH(end:Point) : void
this.h = Math.abs(end.x - position.x) * _standardCost + Math.abs(end.y - position.y) * _standardCost;
this.f = this.h + this.g;


public function setH(end:Point) : void
this.h = Math.max(Math.abs(end.x - position.x), Math.abs(end.y - position.y)) * _standardCost;
this.f = this.h + this.g;

That is, of course, only if you are able to walk diagonally.

This will be fixed in v1.3.

Minor update: v1.1

I’ve added a minor update to Astar. There was a little memory leak in getDataTile() which has now been fixed.

Thanks to Mario Benedek for pointing this out!

You can get the latest version on the A* page.

TextField.setSelection without clicking

If you want to select a certain part of a textfield you use TextField.setSelection. This will only work however if you put it inside a click handler of the textfield.

Why? Because when you click on your textfield it receives focus, which is necessary for setSelection to work.

Solution? First assign focus to the textfield manually and then call setSelection:

stage.focus = tf;
tf.setSelection(0, 5);

Minor update: v1.1

The AstarPath was supposed to be iterated through like this:


But since a lot of people don’t like doing it this way, I’ve added a simple toArray() method to the AstarPath class. The method does what it says: It returns the inner array that the AstarPath uses.

Finally, a website

I finally have a (more or less) decent website! This is actually V5; V1, V3 and V4 were never released and V2 was just a basic WordPress template. Granted, it doesn’t get more basic than the K2 template that I’m using right now, but it’s nice enough to release :).

The main goal of this website is to promote the things I create. Momentarily you can only find an AS3 implementation of A* here, but this will certainly change. I’m also going to try to keep up the blogging, but I’m not making any promises.

Enjoy your (probably brief) stay!