Category: actionscript

Thank you Adobe (Macromedia) for Flash

Google trends, Apple, Google Chrome and plenty of developers put a cross on Flash. In my opinion without Flash the current web tech stack might look different.

Credentials

I wrote my first line of code in ActionScript 2.0 it was 13 years ago and it was streamlined with the style of web. Big boom of flash animations, letters flying around and flash menus. In addition I’m putting myself as the worst person on the World in terms of color matching. At the moment of doing it I didn’t know that I become a programmer, I liked PC though.

A couple of years later I was doing more and more programming, some in Pascal, some in C. Neither of them attracted me for more time (before college) so that I was experimenting in Flash, and I enjoy a lot the simplicity of putting a movement to MovieClips, Timeline manipulation or doing mouse actions. During college, I’ve switched focus to C++98, Verilog and SystemC. Probably by accident I started to work in game industry at GameFactory, where I co-developed around 7 titles in Flash and 2 in Unity 4, then at King I’ve started to work as an AS3/C++ Engine developer. All of it doesn’t make me guru neither of language nor of the best practices. I achieved level where I felt comfortable with API and tech and I could utilize well that Flash offers,

Bright sides of Flash

API

I didn’t notice this aspect before, but after working as an engine developer I understood how hard is to provide clean API what is future-proof. As a noob I was able to deduce what some API call will do. For 8 year of working with Flash Player I don’t remember any problem with breaking changes. API was flexible enough to add new functionality, it was smartly designed around passing an extra configuration objects like LoaderContext. For the instance, when they added an asynchronous image decoding, it wasn’t done by an extra argument for function call, it was an extra property of context. KISS in practice.

ActionScript 3.0

I love in place XML:  var xml:XML = <foo><bar/></foo>;

I love Dictionary with weak keys, and Object where you can put other objects as a key.

I love typed Vectors, (And hate a little bit for weak performance even with fixed size, and conversion between them).

I love for each..in loop.

And I was so surprised that JavaScript has none of them. In such a way ECMAScript 4 (ES4) from ActionScript 3.0 is far more developer friendly than ES5 is. In someway ES6 tries the best by adding classes. But there is plenty of other missing features like: final classes, private, public, protected, internal accessors. Explicit inline (This is more compiler feature than language), strong typed (thankfully we have TypeScript), well designed Event System with nice propagation (It’s more like a library feature rather tan language), no confusion with undefined, no confusion with this, and static variables / functions.

 
201 Kudos
Don't
move!

Problem with alpha in BitmapData / PNG

BitmapData doesn’t store each data what we would like to store.

If BitmapData contains transparency (from constructor argument, or loaded by Loader). It is possible to store R,G,B information in concrete pixel only if A component is not 0. That makes some problem with right texture support for Stage3D

 
1 Kudos
Don't
move!

Don’t use ||= operator. Memory leak if there is no coerce.

Adobe scout is great profiling tool sometimes is annoying but only in usability wise.

During profiling application life cycle I have found some peeks of GC process. Like here:

bool

 
0 Kudos
Don't
move!

Dictionary vs Object

Recently I was wondering about different between using Object and Dictionary. One of the biggest pros about using Dictionary is possibility to use weak reference in key. This mechanism do not create an obstacles during Garbage Collection. Important fact is that weak references is quite expensive for collecting process, there is impact on overhead.

I have crated some test to show differences between Objects and Dictionaries.

 
0 Kudos
Don't
move!

FlashDevelop is on the GitHub!

Regarding to forum post: (http://www.flashdevelop.org/community/viewtopic.php?f=1&t=10961)

We finally did it: FlashDevelop is now under git.

For obvious size reasons (unless you want to download a gigabyte of git objects) only the current state of the code has been archived.

The svn repository will remind us of our long history: in 2004/2005 there was nothing like github. Even Google code only appeared in March 2005 and it quickly became FlashDevelop’s code home.

In the last few years git tool, hosting and clients have become a lot better than the svn offering (does Google still cares about Google code?) and we realize that svn makes us waste a lot of time, especially for a relatively large project with lots of contributors like FlashDevelop.

And there it is, fork FlashDevelop on github:
https://github.com/fdorg/flashdevelop

For good measure, I’d like to remind that bitbucket is another fantastic host, offering even free private repositories for small projects. The company behind bitbucket offers the great, and crossplatform, SourceTree client for free (github tools are toys in comparison).

Now we have an opportunity to improve the best open source IDE to Flash. Move to C# in quite easy.

Enjoy!

 
0 Kudos
Don't
move!

Fun Fun Fun with Array and Vectors conversion

One of the most important benefit of using vectors is performance, and ability to fixing memory.

Arrays are better in:

  • copying whole structure (Array to Array, using slice())
  • as a source to create typed Vector (using statement: Vector.<T>(sourceArray))

Vectors are better in:

  • iteration over collection by index
  • more familiar in IDE (auto-complete syntax of generic)

But what is the range of those benefits and how write program to see the difference?

 
0 Kudos
Don't
move!

Flash main loop

Flash is platform like another one, but specific is that we have a quarantined loop cycle.

Ramka

 

That means if we set 30 FPS in our app/game that in the best way we achieve exactly 30FPS (or less in some cases), and each next ENTER_FRAME broadcast event will be dispatched in next 33,(3)ms. Rest of this time will be spend in idle mode. 

 
0 Kudos
Don't
move!