Archive for the ‘Dev’ Category
Tuesday, November 28th, 2006 |
Here are some hints on how I organize my Eclipse workspace that you might find interesting if you want to keep all the stuff together in one workspace, not only the projects but also shared classes, API docs and default Ant build files.

I’m only using one workspace for all projects, no matter what technology they’re using. I’ve heard others are using one dedicated workspace for every technology and that’s fine too but I find it more practical to just use one for all. I’ve created three sub folders in the workspace named .classes, .default and .docs. Note the period at the beginning of the name. This keeps them listed before all other folders (unless you name your projects with a starting period).
The .classes folder contains subfolders for every technology (or language) I use, namely as2, as3, haxe and java. From there on the ongoing structure depends on the language. For as2 I have folders like additional, mm7, mm8, mtasc, zinc etc. For as3 I only have additional and and swc. The additional folder contains all kinds of third party packages, the swc folder only contains swc files etc. whereas for as2 the mtasc folder only contains the classes that ship with MTASC etc. Here’s a diagram of the structure …
(more…)
Filed under Dev, Random Picks | 4 Comments »
Friday, November 24th, 2006 |
While reading Advanced ActionScript 3 with Design Patterns I’ve once again came across the AS 3.0 Singleton solution that has to deal with the absence of private constructors (I’ll save my rage and cursings about who had the idea to remove them for now ;)) and while the authors are using the already well known method of using a SingletonEnforcer class outside the Singleton’s package to verify that the class cannot be instanciated via the constructor they also note that this can be doublecrossed by giving null or undefined as a constructor parameter. As this is rather sub optimal I was wondering why they don’t just check inside the Singleton constructor for a null/undefined argument and throw an exception accordingly?!
I’m sure somebody else had the same idea already but here’s my idea of a waterproof Singleton class that cannot be misused from the outside (As always, if I missed any detail that accidentally breaks hell loose feel free to correct me) …
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| package
{
public class WaterproofSingleton {
static private var _instance:Singleton;
public function Singleton(singletonEnforcer:SingletonEnforcer) {
if ((singletonEnforcer as SingletonEnforcer) == null) {
throw (new Error("Direct instantiation of a Singleton is not allowed!"));
}
}
public static function getInstance():Singleton {
if (Singleton._instance == null) {
Singleton._instance = new Singleton(new SingletonEnforcer());
}
return Singleton._instance;
}
}
}
class SingletonEnforcer {} |
Filed under Dev, Random Picks | 6 Comments »
Thursday, November 23rd, 2006 |
I’ve been reading this book by Joey Lott and Danny Patterson since yesterday and thought I’d loose a couple of words about it …
The book starts with a chapter about application design where it explains how to go through the analysis-, design- , implementation and testing phase. It introduces how to utilize Use Case- and Class Diagrams and then gives a lesson on how to use FlexUnit for unit testing. In the second chapter is a good explanation about why and how to use Interfaces (instead of Inheritance) and after that it goes into detail with teaching nine of the more common Design Patterns, namely MVC, Singleton, Factory/Template Method, Proxy, Iterator, Composite, Decorator, Command, Memento and State. In part 3 of the book you’ll find in-depth information about AS 3.0 features like Events, data IO, E4X and Regular Expressions.
(more…)
Filed under Dev, Random Picks | 3 Comments »
Monday, November 20th, 2006 |
This might be old news for you but I’ve just coincidentally stumbled over an ActionScript 3 class named FZip that was written by Claus Wahlers and Max Herkender which provides functionality to load standard Zip compressed files into a Flash movie and unpack them on-the-fly. This is amazingly useful and I can see a lot of possible use for it in the future.
It also reminds me of an AS 3.0 framework that I started to write a while ago which provides all kinds of file reading and writing means. It can read and write compressed and uncompressed XML-, text- and binary files. The file writing is currently only done by use of mdm Zinc but support for other data storing methods like for example LSOs are planned and I can imagine that this could be extended with native file writing once Apollo is live. Also the compression it uses is based on AS3’s own ByteArray GZip compression but it writes it’s own custom header tag to the files to identify the file type, compression, original file suffix etc. Eventually I also started to add encryption classes so the compressed data can be encrypted before.
However this started as an offspring from my current game development project where I want to use it to keep external data files compact and it is still in beta. Now that I found FZip I’m thinking about adding support for it as well so the publish date for this is delayed a bit more.
Filed under Dev | 1 Comment »
Saturday, November 18th, 2006 |
I’ve been using Interfaces a couples of time now when needed but I never fully understood those down-sized Class construct wannabes. I knew they are useful when it is required to have an universal type for different objects but I haven’t fully grasped to scope why they are so useful otherwise. Also the fact that they can’t contain properties and only public method declarations confused me.
(more…)
Filed under Dev | 2 Comments »
Monday, October 16th, 2006 |
A couple of days ago the ActionScript 3.0 Cookbook has been published. Obviously it’s a Must-Have but so far I resisted to buy it, waiting for some User Reviews on Amazon. Anyone else got it already? I would be interested in if many new stuff is covered or if it’s just a AS3.0 fitted version of the older AS Cookbook (though I doubt that when I read the authors names).
Then there is the highly anticipated Flex 2 book which is due for the 1. quarter next year and so it still takes a while until then. Another book I’m looking forward to is Advanced ActionScript 3 with Design Patterns, also by Joey Lott, especially because I still haven’t fully grasped patterns. Maybe this will help.
Filed under Dev | 4 Comments »
Wednesday, September 27th, 2006 |
It was about time! According to PowerFlasher a new (and free) update of FDT is due in October. But it will not support AS3/Flex, this will come in quartal 1/2007.
I still need to use AS2 very often for jobs so it’s good to see the Eclipse 3.2 incompatibility being fixed very soon. However I’m using Flex Builder (plug-in) more and more to get on with AS3 and Flex and it’s hard to miss all those great features from FDT there! Therefore it would be awesome if Adobe is providing an update for Flex Builder in between. Some very helpful features from FDT that I’d love to use for AS3 are templates (we all use them, they make coding a lot faster) and Mark Occurances (this might seem inferior but once you used it you know that it is the number one killer feature). Another thing that bothers me is that one needs automatic build active to have compile-time error reporting. It would be cool if the Flex Compiler would report errors on-the-fly like MTASC does it, so I can turn off automatic build and use Ant for building instead which I prefer.
Filed under Dev | 1 Comment »
Thursday, August 31st, 2006 |
flashfilterlab.com … quite awesome! In case you’ve missed it, you can create your own Flash 8 Filters in a Construction Set-like environment where you connect virtual cables to generator boxes (think Maya’s Hypershade or Native Instruments Reactor). I haven’t touched the Flash 8 Filter stuff that much so far (mainly because non-Flash 8 jobs who keep me away from it *grrml*) but I think it’s about time as the lab demonstrates how much potential is in that. It’s a pity though that calculation-intensive Flash’s Bitmap/Filters are still too CPU demanding for most realistic applications.
Filed under Dev | 1 Comment »
Wednesday, August 30th, 2006 |
In ActionScript it was common knowledge that shorter Variable and Function names yielded better performance in situations were it depends but does that still hold true for ActionScript 3.0? I’ve ran a couple of quick tests to find a clear answer about this. I usually tend keep my Variable/Function names to 1-3 characters when performance really mattered but it might actually not be necessary. Consider the following test …
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| package
{
import com.hexagonstar.util.debug.Debug;
import flash.utils.getTimer;
import flash.display.Sprite;
public class PerformanceTest extends Sprite
{
private var aVeryVeryLongVariableNameaVeryVeryLongVariableName:Number;
private var num:Number;
public function PerformanceTest()
{
var startTime:Number = getTimer();
for (var i:int = 0; i < 4000000; i++)
{
aVeryVeryLongVariableNameaVeryVeryLongVariableName = (i * Math.random()) * 100;
}
var timeTaken:String = getTimer() - startTime + " ms";
Debug.trace("timeTaken (long): " + timeTaken);
}
}
} |
I’ve ran this code ten times with the 50 characters long variable name and then ten times with a 3 characters long one, both in their own SWF’s. The results ranged from 757ms to 820ms, more or less the same on both sides. The sum of the long variable version was 7924ms and the one of the three characters long one was 7903ms, not much of a difference.
The next test was similar but this time with a 50 characters long Method name and the other again with a 3 characters long one, the Methods returned a random Number for 4000000 times during this test. The results looked similar but the total sum of each test gave a 12044ms for the long name test and 15570ms for the short named one. A noticable difference of over 3 seconds. This might have been coincidence but I’ve ran the tests a couple more times and it turned out every time that the result were very close together. This is quite interesting because I was safely believing that short names would still have an advantage. It might be time to rethink this.
Filed under Dev | 5 Comments »
Sunday, August 20th, 2006 |

I’m currently developing a role-playing game in AS3.0 (non-fantasy themed!!) in my spare time. This has been and still is in the design phase since a while and I’m pondering whether to use isometric graphics or an orthogonal view (that has a slight tilt but still is fully orthogonal. If you remember Jagged Alliance you get the idea). Though orthogonal view would make things easier I feel that isometric view gives more visual freedom so I will probably end up with that.
(more…)
Filed under Dev, Random Picks | 26 Comments »