I recently started working on a project using Flex 4, the project is basically a port of an existing application to Flash 10 (using Flex 4); so that we can have a version of the application that works in any browser. So over the next few months I’ll probably be posting more about Flex 4/ActionScript 3 than on .NET, I’ll still try find some time to do .NET posts though.
This post is basically just an introduction to what Flex and ActionScript are, and some random things I’ve learnt about them.
I have to admit when I was first told that I’d be working on a Flex application I wasn’t particularly happy, I’m not a big fan of Flash or scripting languages; but I have to say after working with it for a while I’m pleasantly surprised – it’s no .NET but for a scripting language it’s pretty good.
Flex is basically a library that sits on top of Flash providing developers an easy way to create Flash applications. For developers like myself the idea of having to create a Flash application with Flash CS4 is absolute hell; frames, movies, timelines and all that nonsense. So Adobe created the Flex library and the Flex IDE for developers like me that want to code in the traditional sense
I think Adobe have done a pretty good job given the constraints they were under building on top of the Flash framework; it’s not perfect by any means and it’s lacks a lot but much better than I was expecting.
Now I must make a clear distinction, ActionScript is Adobe’s implementation of the ECMAScript specification, so any limitations I mention are limitations of ActionScript and the ECMAScript specification; I’m assuming of course that Adobe has implemented the specification fully . Also, ActionScript is not a Flex thing, it is part of Flash.
Some random things about ActionScript 3.0:
- Requires Flash Player 9.0 or higher.
- There are no abstract classes or abstract methods.
- Does not have a concept similar to .NET generics or C++ templates
- Classes and class members can be private, protected, internal, or public.
- Has static class members but not static classes.
- No enumerated types.
- Properties are defined using get/set functions.
- Has interfaces, yay!
- Has exceptions and exception handling using try…catch…finally blocks.
- Anonymous functions are allowed.
- Has compile time type checking (it can be turned off if you really want it off )
- If you name your function/field the name as a class (case sensitive) you will need to fully qualify the type declaration.
Some random things about Flex:
- Collections/lists are weakly typed, i.e. Array and ArrayCollection hold the type Object.
- Has packages; which are a similar idea to .NET namespaces
- Internal does not have the same meaning as in .NET, internal in Flex means within the current package, not the current project.
- All file loading is done asynchronously with callbacks.
- The “event model” is weird (i.e. not true events), to “raise” events your class needs to inherit from EventDispatcher and classes hook into events on your class using the addEventListener method and specifying the string name of the event to hook into.
- You cannot define a signature for event handlers.
Just a quick disclaimer, I’m still new to Flex/ActionScript so hopefully everything I’ve mentioned here is correct
If you think I’m wrong about something, please let me know.