/customers/iconara.net/iconara.net/httpd.www/blog/wp-content/plugins/wp-super-cache/wp-cache-phase1.php Iconara » 2008 » May

Archive for May, 2008

ActionScript generics in Flash Player 10?

In the prerelease version of Flash Player 10 there is support for type-safe lists in the form of the new class Vector. The class is an example of a parameterized type, meaning that you can have a vector of strings, a vector of display objects or a vector of any other type you like. Parameterized types are called “genetics” in Java and “templates” in C++ and it’s a really nice feature to have.

Unfortunately it seems like you can’t write your own parameterized types, Vector is what you get. Hopefully this is the first sign of things to come, perhaps there will be more in the next version of the player. Watch this space.

Just to check I’ve also tried some other ECMAScript 4 features like let, type and generic functions, but none seems supported.

Update: Seems like the parameterized types doesn’t work very well with push, shift and other array manipulation methods, they accept any type, even though they shouldn’t (likely because are implemented using variable argument lists, which is one of the cases where ActionScript’s typing system breaks down). Also, it breaks down for nested types like var list : Vector.<Vector.<String>> (which allows any vector type to be assigned to the vector, which it shouldn’t. This line should not compile list[0] = new Vector.<int>(), but it does).

Mate, an unobtrusive Flex application framework

If you are tired of application frameworks that tie your code together and makes it an unwieldy mess, take a look at Mate.

Mate is quite unintrusive, lets you configure your application declaratively in MXML and does most of the boring things for you. Judging from the documentation and examples it looks like good competitor in the less-than-crowded marked of Flex application frameworks.

The core of Mate is something called the event map which describes what should happen when your application dispatched events of different types. For each event one or more handlers can be invoked. A handler can be everything from calling a method on an object, running a command or invoking a remote object call and there is room for writing your own specialised handlers. Handlers can also run in sequence and get hold of the previous handler’s result, which makes it possible to create quite complex logic. All this is done in MXML, which means that your configuration is also the actual wiring of your application — and it’s readable and quite easy to understand.

My only objection is how Mate handles updating of views. If I understand it correctly, there are two ways, either you have an injector which looks up the view and pushes values into it, or you have an instance of a dispatcher in your view where you listen for result events and update accordingly. Both remove the benefits of bindings, and while they are certainly better than the global variable lookup of other Flex frameworks, I’m not sure I like them. On the other hand I think you can skip that part and inject the model into the views directly. On the third hand, injectors can potentially make your code more decoupled.

Update: see comments below for a clarification on this issue by the framework’s author.