My adventures with Flash and ActionScript

Posted on:March 28 2007

I am trying to learn at least one new programming language each year. Most programming languages are imperative, so this isn't very difficult if you are a bit experienced already, although I also had fun with several functional languages. This year, I tried out ActionScript/Flash, because it's quite popular today.

My review as C++ programmer: I noticed very soon that Flash/ActionScript really is a framework for creating animated banners for websites only. Everything else you can do with it is built around this banner-framework, so if you want to create something a bit more sophisticated, you'll struggle with lots of problems. The major problem is that ActionScript is simply slow. Try calling one single simple method in a nested for loop each frame and you'll get punished by a drop of framerate by about 90%.
The image on the left shows a program I tried to create, writing a simple iso engine in pure ActionScript. The engine simply renders scrollable iso tiles of a 100x100 map, and it is extremely slow. When I wrote something similar nearly 10 years ago using Delphi on my Pentium 60, the output rate was higher. The slowness doesn't have to do anything with the graphics, it's only the loop which calculates the tile positions. There are ways to improve this for example by inlining calls manually, but that's very exhausting and IMO should not be necessary anymore today.
But apart from this, Flash is quite a mighty framework, targeted at graphic designers.


What about the new Flash9 that supposedly has JIT compilation for ActionScript? I haven't tried it, but it's said to be much faster.
Aras Pranckevici
2007-03-28 18:21:00

The slowness doesn't have to do anything with the graphics, it's only the loop which calculates the tile positions.


Why do you calculate tile positions in a loop?
2007-03-28 21:37:00

yep, JIT will improve this a bit, I think. Lets see :)

Why calculating the tile positions in a loop: Why not? That's the usual way to do the same calculation over and over again, when programming, right? :)
2007-03-28 21:41:00

You should try Flash 9 - it's 10x faster than flash 8.
2007-03-28 22:01:00

Ten years ago on delphi. Dungeons and Dragons?
Armin Ronacher
2007-03-28 22:30:00

close: "Fire & Dragons".
2007-03-29 08:30:00

I wanted to learn flash but it seems it's actually for designers, not programers, whatever you can do in flash (more sophisticated stuff like a game) you better do it in Java.
2007-03-29 22:44:00

sorry niko, since you already know that webdesign does not belong to your main talents, you should not distract yourself with such side-projects. Focus on your main projects, I know what I am talking about, because I once also tried to become a successful freelance programmer...
2007-03-30 10:13:00

@geoffrey: do you honestly think he started programming because he was already an expert in it?
2007-03-30 12:02:00

niko: I remember that game. I was very, very surprised when I found out that you are the developer of that game. I once played that game when I was about 11 years old :D

Armin Ronacher
2007-03-30 16:35:00

flash is painfully slow. i once tried to write a simple bomberman clone:
in this configuration it's already bringing the VM to it's limits. any more enemies or players and it would be unusable.

OT: try D as next year's language, if you don't know it, yet ;)
2007-03-30 17:13:00

when i last programmed flash (i got money for it, otherwise i wouldn't have) i realized that usual graphics output practice is not that well suited. you can do a normal ISO engine (there are even ready-made toolkits for that), but i wouldn't recommend. it is usually better to make it look ISO without being ISO (use big background tiles, and maybe just do your sprite coordinate calculations ISO style). this actually worked quite well, and you get playable framerate (yep, it was a game) even on moderate machines ('fast' is an adjective i would never use in any context that has to do with flash, same goes for 'user friendly', and even when they did huge improvements in Flash 10, i doubt that i could use 'fast' with it...)
2007-03-31 19:13:00

I've just recognized that your image is a fake! The zoomed FPS (27.67) is not the same as in the screenshot (28.29)! Shame on you! ;-)
2007-04-10 18:51:00

ah, funny, you're right. I made several shots and copyied them into gimp, looks like i grabbed the part from one image and pasted it onto another one :)
2007-04-10 19:47:00

Add comment:

Posted by:

Enter the missing letter in: "Inter?ational"




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]