My adventures with Flash and ActionScript

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.

fourteen comments, already:

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 Pranckevicius () (link) - 28 03 07 - 18:21

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?
Lino - 28 03 07 - 21:37

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? :)
niko - 28 03 07 - 21:41

You should try Flash 9 – it’s 10x faster than flash 8.
WhiteNoise (link) - 28 03 07 - 22:01

Ten years ago on delphi. Dungeons and Dragons?
Armin Ronacher () (link) - 28 03 07 - 22:30

close: “Fire & Dragons”.
niko - 29 03 07 - 08:30

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.
trunks14 - 29 03 07 - 22:44

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…
geoffrey - 30 03 07 - 10:13

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

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

Regards,
Armin
Armin Ronacher () (link) - 30 03 07 - 16:35

flash is painfully slow. i once tried to write a simple bomberman clone: http://mainia.de/bomberbot/
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 ;)
Jascha - 30 03 07 - 17:13

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…;)
xaos - 31 03 07 - 19:13

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! ;-)
oli - 10 04 07 - 18:51

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 :)
niko - 10 04 07 - 19:47


Name:  
Remember personal info?
yes
no
Email (optional):
URL (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile

  ( Register your username / Log in )

Notify: Yes, send me email when someone replies.  

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.