Primary links

Secondary links

Languages

Search

Ohloh Profile

Flash versions

For the age of the internet, Flash has an extraordinarily long history, stretching for almost 15 years since its introduction in 1996. It's had to adapt continually during this time, developing from a simple animation format with limited user interaction to add network connections, video, camera and microphone access, remoting and two separate versions of an extensive scripting language.

It's no surprise, then, that there's a complex versioning system to handle the varied capabilities and behaviours of these vastly different formats: today's players should be able to play the earliest SWFs as well as the latest. More precisely, there are several parallel systems that affect behaviour in different ways.

SWF files comprise a header followed by an arbitrary number of "tags". These tags contain all the information needed to execute the SWF, such as image data, vector shape definitions, font data, instructions for shape transformations, and ActionScript byte code. Many of these tags have been regularly updated to add new functionality. The original tag for defining vector shapes (DefineShape), has been updated through four versions, each time adding new data fields.

SWF Version

The SWF version is a number encoded into the header of the SWF. It corresponds to the major version of the player that can officially play the SWF correctly. If you try to play a version 6 SWF in the Flash Player 4, it most likely won't work. For most aspects of SWF playback, there's nothing more to the version than that, because the SWF file version has no effect at all on which tags can be executed.

For example, from SWF version 10, GIF and PNG format data is allowed in image tags (DefineBitsJpeg tags). But this doesn't just affect SWFs marked as version 10 or above: if you use PNG data in a version 2 SWF, the Flash Player 10 will quite happily display it correctly. Moreover, even some releases of the Flash Player 9 support PNG and GIF. It's simply not officially documented. As far as support for SWF tags is concerned, the SWF version is almost completely irrelevant.

For ActionScript 2 (AS2) execution, however, the SWF version can make a big difference. In order to support multiple versions of the language without breaking existing code, parts of the Flash ActionScript API can be hidden depending on the SWF version. To allow this, all objects have a "visibility" flag. For instance, version 8 introduced the "flash" package: a collection of classes for geometry, external communication, text rendering, bitmap handling, and filters largely implemented in ActionScript with a few native functions. All these classes are attached to a global object named _global.flash.

In any version below 8, this object is hidden by default. If it weren't, code like the following, which is commonly produced by the Adobe compiler tools as part of declaring a class named "flash" - which was entirely legitimate before version 8 - would suddenly fail to work:

Changing the version number, then, can have a major effect on the way AS2 is executed. It's easily possible to unhide those properties and have a

Using version 4 has still more crucial differences: this version used AS1. AS1 and AS2 use the same VM and opcodes from the two versions can be used interchangeably. However, AS1 has no _global object, so that none of the AS2 Flash API is present.

VM Version

There is a still more important version difference: the version of the ActionScript Virtual Machine (AVM). This determines whether the player will execute AS2 (using AVM1) or AS3 bytecode (in AVM2). Despite similarities in the language, the two versions of ActionScript are completely distinct, running in separate VMs, with radically different bytecode, and with no means of direct communication with each other.

The VM version is completely unconnected to the SWF version. The fact that Flash Player 9 is the first version to support AS3 leads many people to associate SWF version 9 with AVM2. But in fact SWF version 10 can use AS2, while a version 5 SWF can use AS3.

This is in line with the way other tags are interpreted: AS3 bytecode is contained in ABC tags, while AS2 bytecode uses DoAction tags. Just like other tags, the only thing that determines whether they are parsed is the Flash Player version. However, to determine which version of bytecode is executed - it's possible for one SWF to contain both types of bytecode - there is a flag in the header. The AVM version that the player isn't affected by the SWF version or which tags are present, but depends exclusively on this flag.