Category Archives: Rants

Actionscript — likes and dislikes


I’ve been using Actionscript 3 as part of my game programming class for almost a month now. Coming from a C++ background, there were a lot of things I didn’t like about it the first day. Some of those things I’ve grown to like; others…not so much.


Things I like about Actionscript:

The import system

In AS3, libraries are built on the “one class, one file” paradigm. Each class must reside by itself in a file with the same name as the class. At first I thought that this was just a needless imposition; coming from C++ where every class can be in one file, it seemed silly to me that a language would restrict the freedom of the programmer in that way. As it turns out, this is possibly the thing I like best about the language.

AS3 classes are organized in “packages”, in a similar way that C++ uses namespaces. A package is a folder that contains class files, and is usually named according to Java naming conventions; for example since my website is, my classes are in the folder hierachy com/jacobalbano/, resulting in the package com.jacobalbano.

The beauty of this system is that the source is always exactly where you expect it to be, as opposed to in C+, where hunting down a class definition in a source tree can be a pain. Additionally, there is no concept of definition and implementation, since each class is contained in its own file.

Getters and Setters

In C++ classes, modifying or accessing private member variables requires two functions, usually defined as SetVariable() and GetVariable(). Actionscript streamlines this pattern with getter and setter functions, which take this form:

This allows access to the private variable _ID like this:

The beauty of this system is that it allows the convenience of a public variable without the problem that setting a variable is often not enough. For example, to start an animation with a class in C++, you’d have to use the following style:

The PlayAnimation() function in the above case might stop the current animation and start the one specified in the function’s parameters. In Actionscript, the procedure would be the same, but the interface is different:

In this case, the setter function would perform the same actions as PlayAnimation(), but in a cleaner way, in my opinion.
In addition, member variables can be made read-only or write-only by eliminating one of the functions.

Super() and function overrides

When extending a class, functions of the base class can be overridden with a function implemented in the derived class. In addition, the base functions can be accessed with the super keyword. For example:

The base function update() is overridden by the derived class, but it is preserved so we can still access it.

Function pointers

I’ve tended to shy away from using function pointers in C++, even going as far as to embed a Lua interpreter to bind actions to a GUI. Actionscript makes it easy to store and use function pointers with the Function type.


Things I dislike about Actionscript:


This is a big one. Actionscript’s syntax (and that of any other ECMAscript-derived language) is close enough to C that I didn’t have a hard time picking it up, but some of the changes are clumsy. I would say the biggest offender is variable declaration.

This introduces another gripe I have…

Actionscript is a GC language.

I know it isn’t cool to manage memory yourself anymore, but I like the control it gives me over the program. Actionscript is very picky about what may and may not be deleted.

Actionscript doesn’t have Enums

Enums are a fundamental part of my programming workflow. I can’t think why they wouldn’t exist within the language, but they don’t.

Actionscript has limited support for class templates

The only class that has template support is the Vector class, and templates aren’t exposed for implementation into custom classes. I managed to fake it a bit, but it’s far from preferable.

Actionscript is platform-specific

I wouldn’t even consider learning a language if it didn’t run on Linux. Fortunately, Actionscript can be developed, compiled and run on Windows, Mac and Linux natively. In this case I refer to the fact that Actionscript only really runs on the Flash or Air VMs, one of which has been discontinued on Linux, and neither of which has particularly good performance.

Actionscript allows developers to be lazy

The Flex compiler won’t complain if you miss a semicolon. Forgot to define a return type for a function? Don’t worry, the compiler doesn’t care. I compile my C++ with every possible warning enabled, so this is another thing that bothers me a lot.

Actionscript doesn’t support overloading

In Actionscript you can only have one function per function name, even if the parameters are different between declarations. This means that you can only have one type of constructor, which gets awkward. In addition, operator overloading is not allowed, so if you want to trace your custom class you’re out of luck.


There’s a lot to like about Actionscript, but it has its fair share of ugly features and anti-features. If not for Flashpunk and FlashDevelop I would have given up on it by now. Ironically, Flashpunk is the best framework I’ve ever used, period, and Flashdevelop is the best IDE I’ve ever used, period. At least they make the language bearable while I have to use it.

What is a game?

I’m taking a class in “Beginning game development”, because I’m a total beginner at game development don’t you know. Anyway, one of the assignments for the first week was to write a report defining what a game is. I’m posting the text here, because why not. I feel like I did a fairly good job, but I’m a programmer, not a writer.

What is a game?

Among ludologists — philosophers who study what it is to play — the concept of “game” has many varied definitions. According to Wolfgang Kramer, a game is any activity that includes a set of rules, a goal, a measure of uncertainty or chance, and competition. Sid Meier, the developer responsible for classic video games such as Alpha Centauri, and the Civilization series put it more succinctly: “A game is a series of interesting choices”. While Kramer was writing about games such as Go, Solitaire and dice, and Meier referred to video games in his definition, I believe that either of these descriptions can be applied neatly to any type of game, be it a Half-Life, chess or football.

Can a game really be classified as such if there is no choice? While strategy games often consist of nothing more than an endless string of choices to make, and games like Deus Ex provide a tremendous amount of freedom, others such as Portal often provide a single path to a goal. However, while Portal is as a whole very linear, the player is given great freedom while solving the puzzle. Choice in video games is important as a means to an end. While a game’s ending may not be affected by the player’s choices along the way, the ability to choose his actions throughout is what makes it a game and not a long movie with checkpoints and quick-time events.

Similarly, a game must necessarily involve chance or uncertainty; whether it be that data is generated procedurally or, as is most often the case, that the enemy’s strategy is unknown, the player should never be in complete control, or indeed removed completely from control. If there is no possibility of failure, there can be no option to win. This is parodied in Portal 2, when one “puzzle” is solved by pressing one button. If chance is removed from the equation, playing the game is reduced to a rote sequence of actions.

All games must have goals, for obvious reasons: it is impossible to win without them. However,
goals are not always specified, and must be discovered or set by the player. In Minecraft or the sandbox mode of Just Cause 2, where no set goal exists, the player will invariably set a goal for himself, from building the Chichen Itza to destroying an entire enemy camp without taking damage. This is not bad game design; quite the opposite in fact. Sandboxes, even more so than strategy games, are probably the best example of games as a “series of interesting decisions”.

Another thing all games must have is a set of rules to govern player conduct. In board games rules are more intrusive that in video games, as an intimate knowledge of the rules is necessary to proceed. However, rules in a video game, while it is not necessary to know every one, are equally important, and even the most nonrestrictive game has hundreds of rules that are essential to maintain consistent behavior. Without order there is only chaos.

Finally, a game must have competition. In games like Call of Duty, Battlefield or Unreal Tournament, the competition is supplied by other human players striving for the same goal; whereas a single-player game like Half Life provides competition in the form of computer-controlled enemies. In this context, however, “competition” can refer to anything that prevents the player from reaching his goal. In Portal, for example, the competition comes not only in the form of hazardous environments, turrets and time limits, but also from the player’s own ability to look objectively at the puzzle and solve it given the tools at hand.

Personally, I think Kramer and Meier’s definitions go well hand-in-hand. I feel that the most important requirement for a game to deserve the title is that of choice. In recent years video games seem to have been straying towards a more cinematic style, frequently removing control from the player to ensure that he sees what the game designer intended, or to perform some action that would be impossible due to the rules of the game. For similar reasons, I don’t consider “You have to burn the rope” to be a real game. An excellent parody, to be sure; but not a real game.