ActionScript

You are here

Programming Finite State Machines in Unity3D using C#

Finite State Machines are quite a convenient design pattern in Game Design, as they allow for quite some flexibility when programming AI behaviour.

English

Loading External SWF Into Another SWF – And Getting the Movie Clip Out of it

When getting an external SWF using a loader in ActionScript 3, you usually not getting the the MovieClip contained within. Luckily, the loader you used to get the SWF has a property content that contains that movie clip – and with that, also the timeline.

Props to Jonas, who told me that. I just hope I am getting it right here, since I finally didn’t use it in my project …

English

Getting Things In and Out of Arrays in ActionScript or JavaScript

Since I have a hard time keeping push(), pop(), shift() and unshift() apart, here’s a little cheat sheet I whipped up:

Array Manipulating Cheat Sheet

Undefined

Dynamically Referencing Variables and Methods in ActionScript

Sometimes, the state of an object decides which method has to be executed. Instead of an unwieldy switch construction like this …

switch (task) {

case "sleep":
sleep();
break;

case "walk":
walk();
break;

}

… you can use the someObject[someExpression] notation. This works for any object, and you can use it to access both variables and methods. All those lines from above become this:

thistask;

English

Extending Functions

Sometimes, you have a function already programmed, and then you need a more refined function, that takes even more parameters. Refactoring? A pain in the ass. Thank god I finally learned how to circumvent that pain:

Make a new, more refined function:

function moreComplexFunction(parameter1, parameter2, parameter3) { //execute stuff }

Then replace the original code in the simple function, replacing the superfluous parameters with standard values:

English

Local Game Designers Meeting 2010-03-25

Introduction to Flixel – a rather comfortable game engine for Adobe Flash. Requires Flex or Flash Builder, but seems rather easy to use: from 0 to a simple platformer in about 15 minutes …

Embedding of graphics in ActionScript 3

Embedding graphics can be a PITA when using professional ActionScript IDEs – i. e. Flex Builder …

Embed-Tag to the rescue:

[Embed(source="url/to/asset.jpg")] privat var Asset:class;

English

First Ideas for an Autonomous Software Agent

(Articles tagged with “Developer’s Diary” are more sketches – ideas and thought processes behind current projects, so that they can be assembled as documentation at a later date. Comments and further thoughts are highly encouraged.)

The exercise consists of creating an autonomous software agent that interacts on a 2D plane. Also, it has to work together with other available agents.

In order to let the agent choose an appropriate action, it should contain a stack with possible tasks with priorities. In every turn, the task with the highest priority is executed.

English