Quickly generating AsDoc

June 17th, 2008

For ease of use i have a small batch file to generate the documentation for my ActionScript projects. It’s definitely nothing special, but if you struggle with the asdoc syntax and you just want a quick solution, here it is:

@echo off

set asdoc_bin="E:\projects\flex_sdk_3\bin\asdoc.exe"
set aswing_path="E:\projects\aswing\trunk\AsWing\bin"

%asdoc_bin% -doc-sources org\dirty_motherfucker\. -main-title "My ActionScript Project" -output "doc" -compiler.library-path %aswing_path%

pause

It also points asdoc to the bin directory of AsWing, where it will find the .swc files needed so it can fully understand each part of the sources in my namespace.
If you use several libraries, you will have to supply the library paths as well.

Now, let’s say you don’t have every library available as .swc and you also don’t feel like compiling one. Then you’d use -compiler.source-path. Here is an example of a project that uses more libraries.

@echo off

set asdoc_bin="E:\projects\flex_sdk_3\bin\asdoc.exe"
set aswing_path="E:\projects\aswing\trunk\AsWing\bin"
set aswingkit_path="E:\projects\AsWingKit\src"
set puremvc_path="E:\projects\PureMVC\src"
set tweenlite_path="E:\projects\TweenFilterLiteAS3"

%asdoc_bin% -doc-sources src\org\dirty_motherfucker -main-title "Content Delivery Framework" -output "doc" -compiler.library-path %aswing_path% -compiler.source-path %puremvc_path% %aswingkit_path% %tweenlite_path% src\ -warnings

pause

Also, note in this second example that i include src\ in the source paths. I only generate the documentation for the files in my namespace, but those use source file which reside in the same project directory, thus you should include the whole source directory to make sure everything runs smoothly.

Updated Processing works

May 26th, 2008

I updated all the processing works to use a more common code base. Additionally i added start/stop functionality to the small versions displayed directly in the blog.
I also fixed a few minor (and some major) issues in the Sand Traveler project.
In the original code you will find the following line:

float tinc = ot+(1.1-t/num)*2*t*TWO_PI/num;

which i ported to:

var tinc:Number = ot + ( 1.1 - cityIdx / NUM_CITIES ) * 2 * cityIdx * MathHelper.TWO_PI / NUM_CITIES;

Now cityIdx (t) and NUM_CITIES (num) are both integers. Java (Processing) will correctly do the integer division (which always results in 0). Thus the whole term “(1.1-t/num)” always equals 1.1.
Now the Flex compiler has a different opinion on how this should be evaluated. The presence of 1.1 makes it cast cityIdx and NUM_CITIES to Number as well.

This whole drama led to further errors in the original port. You can grab the fixed source from svn://dirty-motherfucker.org:8888/processing/trunk

Here are the new stand alone versions:
Buddahbrot
Happy Place
Sand Traveler
Substrate

BuddahBrot in AS3

May 22nd, 2008

2008-05-26: I fixed some parts of this port. For further details check the updated works post.

For this one i have to credit quite a few people.
As always, i started out with the Processing source by Jared Tarbell. He based his code on an implementation by Paul Bourke, who based his work on a technique invented by Melinda Green.

It’s pretty much a straight ahead port of Tarbell’s code. Nothing to say about it. Click it to activate it. This is the version with a bailout value of 20 (nice looking results fast).

I didn’t package up a .zip with the source. But you can get the latest versions of all my processing ports from: svn://dirty-motherfucker.org:8888/processing/trunk
I also changed some of the other ports in the meanwhile. Some small bugs slipped in the versions i uploaded to the blog. So if you’re interested, be sure to grab the latest sources from the repository.

Jared Tarbell’s “Sand Traveller” in AS3

May 22nd, 2008

2008-05-26: I fixed some parts of this port. For further details check the updated works post.

I saved one of my favorites by Jared Tarbell’s for now. The algorithm amazed me almost as much as Substrate did, but when i decided to port Tarbell’s works i knew i could put a little sugar into this one.

I started converting it straight ahead but i also added new blending modes. This implementation is basically Tarbell’s third variation of the original implementation. I made it so that the traveler’s sandpainters will either pick additive or subtractive blending. This leads to some pretty nice results.

I didn’t add a smaller version inside this post as it needs some time to develop and it also needs a certain size so you can fully appreciate it. So please check out the large version (1000×1000).

Be sure to also grab the source and check out the originals by Tarbell.

I also added a preview version:

Jared Tarbell’s “Happy Place” in AS3

May 15th, 2008

2008-05-26: I fixed some parts of this port. For further details check the updated works post.

I finished another one of Jared Tarbell’s works. Based on the experience with Substrate, this port was straight-forward.

I also just gave the new Flash Player 10 Beta a run for it’s money. I can only recommend installing it for a test runs on these Processing ports. On my Core2 Duo E6600 with FP9 one core is usually maxed out drawing these demos with reasonable speed. With FP10 i get fluid performance with CPU time to spare.

So here it is (click to start):

There is also a larger version (900×900).

As before you can also grab the source code.

Jared Tarbell’s “Substrate” in AS3

May 13th, 2008

2008-05-26: I fixed some parts of this port. For further details check the updated works post.

Through a long web discovery session, i have come along the website of Jared Tarbell lately. If you aren’t familiar with his works you should definitely have a look.
Needless to say i was very impressed by his procedural image generation approaches, which are based on Processing.

So i decided to port some of his projects to ActionScript3. I have to admit that this wasn’t really a big task, as the source code can practically be copied & pasted directly into FlashDevelop and can be compiled to an SWF.

Something should be noted nevertheless. To achieve acceptable performance in a project like this it is fundamental to work directly with a BitmapData object and not the Graphics instances of the DisplayObjects.
So the only task that had to be done was to write some alpha-blending function and port a handful of Processing specific functions.

So here is my port of Substrate (click to start):

A larger version (1280×720) can be seen here. This version will also restart the animation when a limit of cracks has been reached.

You can also grab the source code and have some fun with it :)

Compiling SWC Libraries - Part 2

May 8th, 2008

dragonworx, a user from the FlashDevelop message board took the time to write an SWC compilation plug-in for FlashDevelop.
So, if you’re a FlashDevelop user and you’re looking to compile an SWC library you should definitely have a look at this.

http://www.flashdevelop.org/community/viewtopic.php?t=2987

I personally have not yet put it to use as i am waiting until solutions are implemented in FlashDevelop and i can build all my crap in one go. Until then i still go for my .bat approach.

Achieving high performance in Full-HD resolution with ActionScript

May 8th, 2008

I recently had to write a rather simple picture viewing application with a little twist. The image display had to be interesting looking, which means blends, filters and movement. In addition to that the display unit had to run in Full-HD resolution (1920×1080).
Now i don’t know about your system, but with my Core2 Duo E6600 something like that brings the Flash player to it’s knees.

Let me give a little more detail on the project and how i solved the issue.
The display unit was divided into 20 slots (5×4 matrix), each slot is filled with an image. The slots should then blend to new images when instructed to.
This gave me the option to divide the display unit into several processes and distribute them on the two cores of my development machine. I planned to write it so it could also be split up into 4 processes on a quad core machine.

Now the whole deal is, as you might have guessed, dividing the work of the whole system to several processors (or cores). The only problem to solve is to synchronize the separate application instances. And this is where the fun begins.

I planned for two machines, one for the display system and one that hosts the content server and the controlling server. The plan to host the content and the controller on a separate machine constructed because this way you could also work with several machines to feed any number of display units.

I tried to write the system to that when any part would fail (crash), that part could be restarted and the whole system would find into it’s place on it’s own.

Now for the details. The display units are PureMVC based and later compiled to .exe with SWFStudio. For the fun of it, i also wrote the server in ActionScript with SWFStudio. I needed the TCP communication capabilities of SWFStudio, because the Flash Player does not provide listening sockets. Of course the server could have been written in any language.

If you would follow the same path you would sooner or later come across the problem of having multiple listening sockets in an SWFStudio application. You can solve that by constructing multiple listening sockets on the same port (somehow that works in SWFStudio) for as many units as you have. I found that to be a rather strange approach though.
So i wrote it so that there is a primary listening socket that, when connected, will negotiate a new connection with the client. It will then instantiate a new instance of the TCP plugin, open a listening socket, tell the client about it and close the initial socket. This will place the initial socket back in the listening state.
The client will then connect the new, dedicated socket and start request information.

At this point the client will be fed with information like, window size, position, client index, the details of the content server and the indexes for the image slots. It will then place itself at the correct position on screen and begin to load the images from the supplied content server.

I designed the display units to be rather stupid and simple. The protocol over which they are controlled is rather simple. But this came mostly from the fact that the job was rather simple to begin with. Over the protocol you could reset all slots to the initial state or tell a slot to fade to the next image.

The server keeps a map of slot indexes to clients. Now when i want to fade images i could choose between several fade patterns (linear, diagonal, random, row-wise, …). I would then construct an object from the specific fade class. That fade would then fire an event when a slot (or several) should be changed.
In the event it passes an array of slots that should be triggered.
Now the server could simply listen to that event and invoke the fade-to-next command over the socket of the client that contains that slot.

That basically takes care of it all. One must be sure to properly handle all socket events. An abstraction for the sockets provided by SWFStudio is highly recommended. When a client dies the socket has to be freed and once a new client connects it needs it’s slot indexes re-assigned.

All in all, this was a very fun project. It’s just nice to kill parts of a system like that and see everything re-organize itself.

Actionscript Maze Generator

April 15th, 2008

If you’ve been checking my blog regularly (yeah, right) you might have noticed that there have been no updates lately (yes i am really sorry).
But i am very grateful for my 100 visits a month, so i have to give you something.

Ok, just for the fuck of it, so you know i am not dead, i am presenting you my maze generator in Actionscript. I actually stole the idea from someone else. but i can’t remember his blog right now (too drunk). And, well, my implementation is way cooler anyway :P

Well, here it is (just a cut-out for design purposes):

But that is not all. In addition to the “random” generation the algorithm can also take a stencil image and use that to modify the result. Where brighter pixels will move the head horizontally and dark pixels will move it vertically. The result can be seen here:

Maze with stencil

There are also other stencils in the same folder, so if you want you can replace the number in the filename and look around.

Btw, this effect seems to work best on a PC screen. When you print out the image, the effect is hardly noticeable. At least in my tests ;)

Abstract Foliage 0.3

March 1st, 2008

I finally came around to touch the abstract foliage script for scriptographer again. I really didn’t add anything new that would be interesting, i mainly did some clean up. I moved all the constants that define the growth into variables and documented them properly in the init section of the script.
I also added some primitive support to draw a shape at the end of a dead branch. Maybe you can have some fun with that.
Anyways here is the script :)