Now my view of ActionScript has changed - radically. ActionScript is no longer merely a language for ‘scripting’ animated graphics - it is a powerful general-purpose programming language. In fact, I’d say that ActionScript is now one of the most important programming languages around.
Just look at what it gives you: it is an object-oriented language with a full range of visual controls for designing user interfaces; it can be integrated with ‘back end’ technologies using other languages and frameworks such as PHP, ASP and Ruby On Rails (see ‘Ruby On Rails With Flex); it comes with a huge and powerful class library (Flex) for developing online, browser-hosted applications or (using the AIR runtime) standalone desktop applications; it has (of course!) excellent graphics capabilities thanks to Flash; it is cross-platform without all the problems often associated with cross-platform deployment - put simply, if users have Flash Player installed then what they see and what they get should be pretty much identical no matter which the operating system or browser they happen to be using; and finally, the Flash Player is ubiquitous - just about everyone has it installed (about 99% of Internet-connected users, anyhow). That’s a lot of users!
We’ll be starting a hands-on series on ActionScript programming in Bitwise shortly (update: part one now online) . In this introductory, article, however, I want to give a simple overview of what ActionScript is and how it fits in with Flex, Flash and AIR...
There’s no escaping Flash. It’s everywhere - from Facebook apps to YouTube videos...
OK, So What Is ActionScript, Anyhow?
ActionScript optionally enforces type declarations and supports the creation of large projects divided up into classes stored in separate files and organized into multiple directories (‘packages’). Source code is compiled into bytecode and can be run by the Flash Player (typically hosted in a web browser) or in the AIR runtime environment (that is, as a desktop application).
Flash, Flex, AIR...? What’s the difference?
Flash is the name of a graphics (and audio) technology which allows images, animations, sounds and video to be displayed and streamed over the internet. Everything from cartoons (such as ‘Badger, Badger’) to YouTube videos are rendered using Flash. A program called the Flash Player is responsible for displaying Flash graphics. Adobe also has a product called The Flash IDE which enables developers (typically animators rather than programmers) to create and script animations on a timeline.
Flex is the name of a ‘programming framework’ for the creation of cross-platform (traditionally these have been browser-hosted) applications. The current version, Flex 3, provides a huge class library, written in ActionScript, supporting string, maths, IO, graphics, XML, data operations and much more besides. Flex has a number of visual components - buttons, text entry fields, images and data-aware controls - which are rendered in Flash and programmed using ActionScript. In early 2008, Adobe open sourced the Flex SDK. Adobe’s IDE for Flex programmers is the Eclipse-based Flex Builder 3.
AIR is the name of Adobe’s cross-platform runtime environment for creating desktop applications using Flex. AIR is an acronym of ‘Adobe Integrated Runtime’ - it is probably not accidental that this acronym also happens to be RIA (‘Rich Internet Application’) in reverse. AIR applications can take advantage of the standard features of Flex plus various native-OS integration features such as file access and drag-and-drop. The current version of AIR cannot access all the features of a native OS, however, so it is not a direct rival to languages such as C++, C# or Delphi. It remains to be seen if more complete OS-integration will be implemented in future versions.
Flex Builder 3 is Adobe’s IDE for programming Flex and AIR
Wot, no Microsoft...?
Oh, did I forget to mention? Microsoft also has a cross-platform programmable streaming graphics technology that can be hosted in web browsers. It’s called Silverlight, it’s the lightweight sibling of WPF (Windows Presentation Foundation) and, if imitation is a form of flattery, Adobe are no doubt feeling very flattered.
On the one hand, Silverlight has some distinct advantages over Flash and Flex. For a .NET-head like me, it has the attraction of familiarity since I can program Silverlight using C# (or other .NET languages). But the big question remains: why should end users care? What is going to entice them to switch from Flash to Silverlight when most streaming graphics are already implemented in Flash?
In my view, if Silverlight is to compete seriously with Flash it need to persuade the end users, not the developers, that the switch is worth making. And I haven’t yet seen the ‘killer feature’ of Silverlight which is going to tempt away all those happy online game-players and YouTube viewers.
What’s more, Silverlight has a huge hill to climb. I don’t know how many people have thus far bothered to install Silverlight on their PCs, but I think it’s a fair bet that it falls way short of the 99% who have Flash installed. Then again, this is Microsoft we are talking about...
Frankly, who knows what may happen in the future? But for the time being, if you want to program browser-based applications with a slick graphics interface, Flash, Flex and ActionScript is the winning combination.
As I mentioned earlier, we shall soon be starting a new ‘hands on’ ActionScript programming series (update: see ActionScript 1 - Associative Arrays). In the meantime, here are some useful resources for learning ActionScript and Flex...
Adobe Flex Developer Center
The official Flex site. Lots of useful help and tutorials: http://www.adobe.com/devnet/flex/
ActionScript Technology Center
Adobe’s site is an essential jump-off point for ActionScript coders: http://www.adobe.com/devnet/actionscript/
Programming ActionScript 3.0
Essential free PDF eBook, available from: http://labs.adobe.com/wiki/index.php/ActionScript_3
Adobe’s Flex IDE. Download a 60-day trial from: http://www.adobe.com/products/flex/
Flex ‘community’ site - news, articles, sample code: http://flex.org/
Also on Bitwise...
Flex - the road to Web 3...? (Adobe Interview)
Microsoft Silverlight for Rich Internet Applications (Microsoft Interview)