Archive for October, 2005
FLASH 8: particle.swarm
Well, it’s about time. I finally opened up Flash 8. I have to say I’m very impressed so far. The interface seems much cleaner, and the Mac version seems to finally work. I’ll reserve judgement on that for a few weeks.
As a test, I wrote a Particle Swarm Optimization algorithm example, which has 60 independent agents looking for a target (in this case, the mouse). I implemented the very cool and really easy BlurFilter Class, giving the agents a bit of snazz. This was a quick, 1 hour example, so there are things that I’d like to fix, but I thought I’d post it anyways, in keeping with my promise to make everything open source.
I had this system running with as many as 100 agents, and it was looking fine… you PC folks could probably run 200 agents without too much problem.
So, check it out, then download the source and play around a little bit. Post in the forums if you have any questions or if you come up with something cool.
Here’s a bit of info on Particle Swarm Optimization, for those interested.
Flash BitmapExporter: Compress and Save Images
Here is a demo for something that I hope may prove useful for some people. I have written a BitmapExporter class which allows to save PNGs or JPEGs out of swf files. There have been some Flash 8 demos already that show this possibility, so the novelty factors of my class are that the images get compressed before they are sent to the server and that Flash remoting is used to transfer the data. On the server side I’m running this with AMFPHP in conjunction GD (which comes usually pre-installed with PHP) to recreate the images.
The demo allows you to doodle some drawings and to save them to your hard drive as a JPEG. Because of its security sandbox Flash cannot access your harddrive directly. It first has to send the image data to the server and then commence a download from there. We are so used to the small filesizes of JPEGs or PNG that it’s quite surprising to see what size an uncompressed image really has. The canvas in this demo for example has a dimension of 500×425 pixels. That’s 212500 pixel x 4 bytes per pixel = 850000 Bytes or about 830K.
The challenge is to create a compression algorithm in ActionScript which will process the image data with reasonable speed without overexerting Flash. I didn’t want to start studying the JPEG or PNG format specifications, so I rolled my own method. It uses an indexed color palette (but without reducing the amount of colors) and a run-length encoded table of the offsets of the colorindices of the consecutive pixels (wow, that sounds complicated). In reality that means that it will compress noisy images not so good as graphics. Therefore I have built in an optional method to reduce the bit-depths of images which does improve the compression ratio for photos and webcam shots.
The image is not necessarily processed in one block - the blocksize can be varied based on package size as well as processing time. Doing this the Flash plugin remains responsive and on top of that it allows for a bit “parallel processing”: whilst the server is receiving data and creating the first part of the image (which takes the longest time in the process), the swf file is already compressing the next data block. Now isn’t that clever?
Process Revealed
The exhibition component of the conference seeks to explore the processes and the relationships between score, image, text and sound. Focusing on the gaps between output and process, ideas and experience, between abstract concepts and their relation to the tangible, process revealed considers the generative, the algorithmic and the evolved in relation to analytical, performative possibilities. The issue is to examine the complex relationship between time-based and static or visual art forms as they converge and mutate one into the other.
You can find more details here. The conference and exhibiton, the 4th European Workshop on Evolutionary Music and Art will be at the Artpool in Budapest, Hungary in April, 2006.
Submission deadline is November 4th.
Live from Botswana…

What a huge waste of time. But damn, if it ain’t entertaining. National Geographic has managed to set up a live webcam feed from a remote watering hole located in a nature preserve in Botswana. What is exciting about this particular webcam is that it uses a satellite link to give us 20-25 fps and full audio. Suckfully, though, it needs the Real player. And there are times when it seems just about impossible to connect or maintain the connection for more than a few seconds. But I leave it on at the office and sometimes it runs for a couple hours without any interruption.

You can hear the splashing of animals bathing. You can hear the wild flap of wings when something spooks the birds. The camera pans around and zooms in on interesting creatures (though at night, it seems to just pan and zoom on a preprogrammed loop), sometimes so close, you can see water drip from their mouths after the come up from drinking. Quite a show, and since it is a live feed, you might luck upon some humping. One can only hope.
Back to work!
My very awaited holiday has already finished and I'm back in London ready for a very intensive fall/winter. For who may concern, here a selection of pictures taken during the travel. As I already said, stay tuned because many projects I'm working on are going to be published soon!
Flash 8: Marching Ants Selection Rectangle
Marching ants rectangles are probably not priority #1 in an application, but they are a nice visual clue to the user that she is currently opening a selection rect. So if you are still looking for a nice “pimp up your app” part, look no further:
This an example for a very simple visual widget that you could also build with the Flash Drawing API, where it would proably become a horrible performance hog having to draw hundreds of tiny vectors. Using the new beginBitmapFill method this tool behaves much nicer and has a very small footprint.
The class allows for custom line patterns and colors and you can change the speed and direction of the ants’ march.
Green-tea Fuelled Creation

Michael Chang is a fourth-year undergraduate at UCLA’s D|MA program, whose faculty includes Casey Reas and Christian Moeller.
His site exhibits four projects that he’s completed in the program. I think I’ve already linked his Manifest project, which generates digital critters based on gestures, but I was also impressed by his explorations into parameterized form. Nice work, Mr. Chang!
That Old Devil Called Back Button Again
Jens Franke’s excellent session on the Flashforum Tour about Flash usability issues inspired me to give the old “Flash breaks the back button, there is no deep-linking possible and there is no way to bookmark pages” problem another go. To make it short: I wasted a day only to find out in the end that Kevin Newman already seems to have developed a solution that works. But let’s start from the beginning.
As you probably know several people have already tackled parts of the problem with success:
- Robert Penner was the first to invent a working back button solution for Internet Explorer
- Chris Hendershot improved Robert’s method so it works also with other browsers and especially on Macs
- Mike Chambers demonstrated a method that also bases on Robert’s method which uses LocalConnection and does not rely on JavaScript
All these methods work with a hidden frame, and do not change the visible URL when navigating. The consequence is that while they enable the back button they do not address the bookmarking problem.
There’s an article by Kevin Lynch which demonstrates how to track states within Flash applications by updating the visible URL and title tag of the html page and thus allowing to bookmark sub-pages of Flash sites. Unfortunately this method does not allow to use the back button.
In theory the whole affair could be so easy to solve with the help of named anchors. Named anchors are like markers within a HTML page which allow to jump to certain positions on a page without reloading it, in HTML they look like this: <A name=”example”>. They are perfectly suited for our purpose because a) they get shown in the URL (http://www.blahblah.com/page.html#example) and b) they register in the browsing history which means you can navigate back and forth and bookmark them.
Macromedia even introduced them in Flash MX. The problem with the way they are implemented is that they are static and do not behave correctly. Static means that you will have to compile them into the swf and cannot generate them dynamically with ActionScript - this makes them pretty useless for sites or applications that get their content or structure from external files, but if you can live with that there is a good tutorial on noscope how to use them.
Unfortunately the internal Flash anchors have an annoying side-effect: when you have for example 4 anchors/pages “one”, “two”, “three” and “four” and navigate directly from “one” to “four”, the browser history will register “one-two-three-four” instead of “one-four”, so clicking the back button will take you to “three” in this case.
So this is where I started from and failed in the end. The goal was to find a method which allows to enable the back button and bookmarking and all this without using hidden frames or static precompiled anchors. It should also work with Flash 6, so I could not use ExternalInterface. The basic idea is very simple: just generate the named anchors inside the HTML page with javascript whenever they are needed and update the browser’s location. Surprisingly this method worked perfectly. Except in Internet Explorer which it crashed. I could nail this crash down to the getURL(”javascript:…”) method I was using and after replacing the call by an fscommand I was able to make that part work even in Explorer.
What I had to discover was that this was only half of the rent. The other problem was to notify Flash when the user had pressed the back or forward button. And again it turned out that Internet Explorer is a piece of sh*t. It could be so easy - just watch the location.hash in JavaScript (that’s the part after the “#” in a url) and tell Flash when it changes. But IE has this unique bug (MS probably calls it a “security enhancement”) that even though the URL visibly changes when you navigate back and forth the location.hash property in JavaScript does not.
This is where I started searching Google and I should have done so earlier, because it looks like other people ended up in the same cul-de-sac. But of course you first have to know the problem before you know how to search for it. And whilst searching for a solution for the IE show-stopper I finally stumbled across this:
It looks like Kevin Newman has indeed found a way to make the back & forward buttons work and bookmarking possible in Flash: his FlashSuite is still under development, but at least in all my Windows browsers it really seems to behave as intended. It uses his HistoryKeeper class which might also be interesting for AJAX programmers as they face some of same problems as Flash developers.
The question is now - how compatible is this method? I think Kevin (and everyone who thinks about using it) might be interested in getting some feedback how and if it works in various browser/OS combinations. So if it doesn’t work for you - please leave a comment or send him an email which combination you were using.
I hope he will clean up the code a bit - at the moment it looks a bit frightening with all those .js includes. A single JavaScript file to include would be very comfortable. And maybe the option to use the meanwhile well established FlashObject for the swf inclusion part.
Some Light Morning Reading

I’m trying to dive into neural networks, and in preparation am reading a bit about modern theories on thought and inteligence. To start things off, I’m reading William Calvin’s How Brains Think.
With a great deal of historical and theoretical background in the first few chapters, Calvin eventually dives into his own theories on thought; namely that it is the result of evolution-like processes that occur in our brains over the briefest of time periods. This is pretty fascinating stuff.
His Website is pretty decent, as well, apart from the Comic Sans. It seems like some of his more recent work has focused on creativity. After I finish the book, I’ll probably dive into his awfully gaudy Powerpoint presentation, titled “Cerebral Circuits for Creativity: Bootstrapping Coherence using a Darwin Machine.” Man, I’m a dork.
Holy freakin crap!

Link from Toxi
I love 3D. I wish I had spent my time learning Maya instead of Flash. Greener grass and all. Part of the fascination is the ‘magic factor’. Not sure of the exact name of the phenominon or if it is a phenominon at all but I kinda remember the gist. Something about showing a calculator to a caveman and him thinking you are god. Or an evil spirit. Cant quite remember, but it was definitely something big. I am the caveman and really damn good 3D is the calculator. Ok, not the best metaphor. Or is it a simile. Sigh, I digress.

I love 3D, not because it is pretty or lush or convincing. I love it because I just have no idea how to do it. Maybe ‘wow factor’ would be more appropriate. I see good 3D rendering and I think “Wow! How the hell did they do that!” I think we all do this to some extent. The danger with this line of thinking is if you are unfamiliar with the tools, then you cannot fully appreciate the amount of work that was put into a piece. The first time someone showed me photoshop pre-packaged lens-flares, I probably said something like, “Oh my holy freakin god! How did you do that?! It looks just like I am looking directly into the sun. But without the squinting and oh jeez, did you just make it all ripply like the ocean! Wow!”
But it was just a single button press. The filter did all the work. I think we all know where the lens-flare effect ended up in our repetoire. Right at the bottom, just under page curl and spherize.
So, when I see something that makes me say ‘wow’, I sit back and think. Is this actually something to ‘wow’ at or is this just a prepackaged effect that anyone in-the-know would realize took all of 2 minutes. After seeing the 1st Ave Machine video, I could easily tell that this was something special.
The light-matching and camera tracking alone is impressive. Near perfect integration of realistic 3D into a filmed scene. I say ‘near’ only because something seemed off. I couldn’t say what, exactly. Cannot put my finger on it. I am going to go watch the videos again. Maybe I will figure it out. But man … Wow.







