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 …
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:
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:
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;
(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.