Jun 8 2009

Phlocks is out!!!

Finally, I managed to release Phlocks - Physical blocks. It is a casual flash puzzle game using the Box2D physics engine. I started playing with the engine in the beginning of this year. End of January I came up with the first version of the game.

This weekend finally, I found some time to pick up that project again and finish it. Ok, try it out yourselves at the following little sub-page:

Phlocks icon

http://www.weltenkonstrukteur.de/games/phlocks/


Jun 2 2009

AS3.0 TutBits #06: Exception handling

Actionscript uses a rather loose throw convention, since you can throw nearly everything - it does not have to be an exception. The throw statement thus looks like this:

throw expression

According to that, the following code is perfectly valid and outputs “Test” :

public function Main()
{
	try
	{
		throwSomething();
	}
	catch ( e:String )
	{
		trace(e);
	}
}
 
private function throwSomething():void
{
	throw new String("Test");
}

However, this is not the normal case. In actionscript you should always throw Error Objects. So, ideally above’s code should be look like this:

public function Main()
{
	try
	{
		throwSomething();
	}
	catch ( e:Error )
	{
		trace(e.message);
	}
}
 
private function throwSomething():void
{
	throw new Error("Test");
}

Of course, you could write your own exception classes which derives from the Error class like you would do it in other languages with the Exception class. Apart from that difference, Actionscript’s Exception handling is pretty straight-forward and sticks to the general paradigm.