Alexis' SWF Reference
(started in June 2002)

summary

This document license

About SWF

  • Brief History

  • What is SWF?

  • The geometry in SWF
  • Table of all the SWF tags sorted by number and version

    How the structures are described

    The File Header

    Descriptions of each tag

  • DefineBits

  • DefineBitsJPEG2

  • DefineBitsJPEG3

  • DefineBitsLossless

  • DefineBitsLossless2

  • DefineButton

  • DefineButton2

  • DefineButtonCxform

  • DefineButtonSound

  • DefineEditText

  • DefineFont

  • DefineFont2

  • DefineFontInfo

  • DefineFontInfo2
  • DefineMorphShape

  • DefineShape

  • DefineShape2

  • DefineShape3

  • DefineSound

  • DefineSprite

  • DefineText

  • DefineText2

  • DefineVideoStream

  • DoAction

  • DoInitAction

  • End

  • Export
  • ExternalFont

  • File Header

  • FrameLabel

  • FreeCharacter

  • Generator3

  • GeneratorText

  • Import

  • JPEGTables

  • NameCharacter

  • Protect

  • ProtectDebug

  • ProtectDebug2

  • PlaceObject
  • PlaceObject2

  • RemoveObject2

  • RemoveObject

  • ScriptLimits

  • SerialNumber

  • SetBackgroundColor

  • SetTabIndex

  • ShowFrame

  • SoundStreamBlock

  • SoundStreamHead

  • SoundStreamHead2

  • StartSound

  • VideoFrame
  • Common Structures

  • swf_tag

  • swf_rgb

  • swf_rgba

  • swf_rect

  • swf_shape_with_style

  • swf_shape_record

  • swf_styles
  • swf_fill_style_array

  • swf_fill_style

  • swf_line_style_array

  • swf_line_style

  • swf_matrix

  • swf_gradient

  • swf_gradient_record
  • swf_color_transform

  • swf_action

  • swf_event

  • swf_external

  • swf_soundinfo

  • swf_envelope

  • swf_params
  • Appendix A

    History of this reference





    This document license

    Copyright (c) 2002-2005 Made to Order Software, Ltd.

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.





    Please, note that MP3 audio encoders and decoders can freely be used as long as you don't generate any revenue from them. If you intend to sell or buy a product which uses an MP3 audio encoder or encoder or both, you most certainly want to know more about licensing issues in regard to that concept. You can find all the necessary information on the following site: http://www.mp3-tech.org/





    About SWF





    Table of SWF tags

    Name Number Type Comments
    SWF Version 1.0
    File Header None Format We can consider the file header as being a tag though it isn't a tag per say.
    End 0 Format Mark the end of the file. It can't appear anywhere else but the end of the file.
    ShowFrame 1 Define Display the current display list and pauses for 1 frame as defined in the file header.
    DefineShape 2 Define Define a simple geometric shape.
    FreeCharacter 3 Define Release a character which won't be used anymore.
    PlaceObject 4 Display Place the specified object in the current display list.
    RemoveObject 5 Display Remove the specified object at the specified depth.
    DefineBits 6 Define Define a JPEG bit stream.
    DefineButton 7 Define Define an action button.
    JPEGTables 8 Define Define the tables used to compress/decompress all the SWF 1.0 JPEG images (DefineBits).
    SetBackgroundColor 9 Display Change the background color.
    DefineFont 10 Define List shapes corresponding to glyphs.
    DefineText 11 Define Defines a text of characters displayed using a font. This definition doesn't support any transparency.
    DoAction 12 Action Actions to perform at the time the next show frame is reached and before the result is being displayed. It can duplicate sprites, start/stop movie clips, etc.

    All the actions within a frame are executed sequencially in the order they are defined.

    Note: some actions are specific to other versions than SWF V1.0. Please, see the reference of actions below in order to know which actions can be used with which version.

    DefineFontInfo 13 Define Information about a previously defined font. Includes the font style, a map and the font name.
    SWF Version 2.0
    DefineSound 14 Define Declare a sound effect. This includes sound samples which can later be played back using either a StartSound or a DefineButtonSound. Note that the same DefineSound block can actually include multiple sound files and only part of the entire sound can be played back as required.
    StartSound 15 Display Start the referenced sound on the next DisplayFrame.
    DefineButtonSound 17 Define Defines how to play a sound effect for when an event occurs for the given button.
    SoundStreamHead 18 Define Declare a sound effect which will be interleaved with a movie data so as to be loaded over a network connection while being played.
    SoundStreamBlock 19 Define A block of sound data. The size of this block of data will be defined in the previous SoundStreamHead tag. It can be used so sound is downloaded on a per frame basis instead of being loaded all at once.
    DefineBitsLossless 20 Define A bitmap compressed using ZLIB (similar to the PNG format).
    DefineBitsJPEG2 21 Define Declare a complete JPEG image (includes the bit stream and the tables all in one thus enabling multiple table to be used within the same SWF file).
    DefineShape2 22 Define Declaration of complex 2D shapes.
    DefineButtonCxform 23 Define Setup a color transformation for a button.
    Protect 24 Format Disable edition capabilities of the given SWF file. Though this doesn't need to be enforced by an SWF editor, it marks the file as being copyrighted in a way.
    SWF Version 3.0
    PlaceObject2 26 Display Place an object in the current display list.
    RemoveObject2 28 Display Remove the object at the specified level. This tag should be used in SWF 3.0+ since it compressed better than the standard RemoveObject tag.
    DefineShape3 32 Define Declare a simple geometric shape.
    DefineText2 33 Define Defines a text of characters displayed using a font. Transparency is supported with this tag.
    DefineButton2 34 Define Define an action button. Includes a color transformation.
    DefineBitsJPEG3 35 Define Defines a complete JPEG (includes the tables and data bit stream) twice. Once with the RGB data and once with the alpha channel. Note that the alpha channel uses the Z-lib compression instead of the JPEG one.
    DefineBitsLossless2 36 Define Defines an RGBA bitmap compressed using ZLIB (similar to the PNG format).
    DefineSprite 39 Define Declares an animated character. This is similar to a shape with a display list so the character can be changing on its own over time.
    NameCharacter 40 Define Define the name of an object (for buttons, bitmaps, sprites and sounds)
    SerialNumber 41 Define ?
    GeneratorText 42 Define ?
    FrameLabel 43 Define Names a frame or anchor. This frame can later be referenced using this name.
    SoundStreamHead2 45 Define Declare a sound effect which will be interleaved with a movie data so as to be loaded over a network connection while being played.
    DefineMorphShape 46 Define This is similar to a sprite with a simple morphing between two shapes.
    DefineFont2 48 Define Define a list of glyphs using shapes and other font metric like information.
    DefineInfo 49 Define Gives some information about the tool which generated this SWF file and its version.
    SWF Version 4.0
    DefineEditText 37 Define An edit text enables the end users to enter text in a Flash window.
    SWF Version 5.0
    Generator3 51 Define ?
    ExternalFont 52 Define ?
    Export 56 Define Exports a list of definitions to other movies. You can in this way create one or more movies to hold a colection of objects to be reused by other movies without having to insert these info in each movie. A single export is enough for an entire movie (and you should have just one).
    Import 57 Define Imports a list of definitions from another movie. You can retrieve objects which were exported in the specified movie. You can have as many import as you like, though you should have only one per referenced movie.
    ProtectDebug 58 Format The data of this tag is an MD5 password like the Protect tag. When it exists and you know the password, you will be given the right to debug the movie with Flash V5.x.

    WARNING: this tag is only valid in Flash V5.x, use the ProtectDebug2 instead in V6.x movies.

    SWF Version 6.0
    DoInitAction 59 Action Actions to perform the first time the following show frame is reached. All the initialization actions are executed before any other actions. You have to specify a sprite to which the actions are applied. Thus you don't need a set target action. When multiple initialization action blocks are within the same frame, they are executed one after another.
    DefineVideoStream 60 Define Defines the necessary information for the player to display a video stream (i.e. size, codec, how to decode the data, etc.). Play the frames with VideoFrame tags.
    VideoFrame 61 Define Show the specified video frame of a movie.
    DefineFontInfo2 62 Define Defines information about a font, like the DefineFontInfo tag plus a language reference. To force the use of a given language, this tag should be used in v6.x+ movies instead of the DefineFontInfo.
    ProtectDebug2 64 Format The data of this tag is a 16 bits word followed by an MD5 password like the Protect tag. When it exists and you know the password, you will be given the right to debug the movie with Flash V6.x and over.
    SWF Version 7.0
    ScriptLimits 65 Define Change limits used to ensure scripts don't use more resources than you choose. In version 7, it supports a maximum recursive depth and a maximum amount of time scripts can be run for in seconds.
    SetTabIndex 66 Define Define the order index so the player knows where to go next when the Tab key is pressed by the user.




    How the structures are described





    The File Header





    Descriptions of each tag

    Name ID Length (Stacked) Data & Operation Comments Version
    End 0x00 0 <n.a.> End a record of actions 1
    Next Frame 0x04 0 <n.a.> Go to the next frame 1
    Previous Frame 0x05 0 <n.a.> Go to the previous frame 1
    Play 0x06 0 <n.a.> Enter the standard (default) auto-loop playback 1
    Stop 0x07 0 <n.a.> Stop playing. Only a button (or the plugin menu) can be used to restart the movie 1
    Toggle Quality 0x08 0 <n.a.> Change the quality level from low to high and vice versa. At this time, not sure what happens if you use medium! 1
    Stop Sound 0x09 0 <n.a.> Stop playing any sound effect. 2
    Add 0x0A 0 (n)
    operation: n2 + n1
    Pops two values, add them and put the result back on the stack. 4 only
    Subtract 0x0B 0 (n)
    operation: n2 - n1
    Pops two values, subtract them and put the result back on the stack. 4
    Multiply 0x0C 0 (n)
    operation: n2 * n1
    Pops two values, multiply them and put the result back on the stack. 4
    Divide 0x0D 0 (f)
    operation: n2 / n1
    Pops two values, divide them and put the result back on the stack. 4
    Equal 0x0E 0 (b)
    operation: n2 == n1
    Pops two values, compare them for equality and put the boolean result back on the stack.

    The != is created by adding a Logical Not after the Equal

    4 only
    Less Than 0x0F 0 (b)
    operation: n2 < n1
    Pops two values, compare them for inequality and put the boolean result back on the stack.

    Other comparison operators:

    • Less Than or Equal (n2 <= n1)
    Swap + Less Than + Logical Not
    • Greater Than or Equal (n2 >= n1)
    Less Than + Logical Not
    • Greater Than (n2 > n1)
    Swap + Less Than
    4 only
    Logical And 0x10 0 (b)
    operation: b2 && b1
    Pops two values, compute the Logical AND and put the boolean result back on the stack.

    Note: if b2 is a function call and b1 is false, then b2 is not called.

    4
    Logical Or 0x11 0 (b)
    operation: b2 || b1
    Pops two values, compute the Logical OR and put the boolean result back on the stack.

    Note: if b2 is a function call and b1 is true, then b2 is not called.

    4
    Logical Not 0x12 0 (b)
    operation: ! b1
    Pops one value, compute the Logical NOT and put the result back on the stack. 4
    String Equal 0x13 0 (b)
    operation: s2 == s1
    Pops two strings, compute the equality and put the boolean result back on the stack. 4 only?
    String Length 0x14 0 (n)
    operation: strlen(s1)
    Pops two strings, compute the equality and put the boolean result back on the stack. 4
    SubString 0x15 0 (s)
    operation: s3[i2 .. i2 + i1 - 1]
    Pops two values and one string, the first value is the new string size (at most that many characters) and the second value is the index (1 based) of the first character to start the copy from. The resulting string is pushed back on the stack. 4
    Pop (0x17) 0x17 0 (i)
    operation: a1
    Pops one value from the stack and forget it. 4
    Integral Part 0x18 0 (i)
    operation: floor(n1)
    Pops one value, transform in an integer, and push the result back on the stack. 4
    Get Variable 0x1C 0 (a)
    operation: GetVariable(s1)
    Pops one string, search for a variable of that name, and push its value on the stack. The variable name can include sprite names separated by slashes and finished by a colon as in:
    /Sprite1/Sprite2:MyVar
    This gets the variable named MyVar from the sprite named Sprite2 which resides in Sprite1. Note that in a browser you can add variables at the end of the movie URL (as defined in the W3C docs) and these will automatically be accessible via the GetVariable instruction.
    my_movie?language=jp

    Since Flash V5.x, there are internal variables available to you. These can be read with the Get Variable instruction.

    4
    Set Variable 0x1D 0
    operation: s2 = v1
    Pops one value and one string, set the variable of that name with that value. Nothing is pushed back on the stack. The names can be full paths as defined in the GetVariable action. 4
    Set Target
    (dynamic)
    0x20 0
    operation: SetTarget(s1)
    Pops one string from the stack. If the string is the empty string, then the next actions apply to the main movie. Otherwise it is the name of a sprite and the followings actions apply to that sprite only. 3
    Concatenate Strings 0x21 0 (s)
    operation: s2 & s1
    Pops two strings, concatenate them, push the result on the stack. 4
    Get Property 0x22 0 (a)
    operation: s2.n1
    Query the property 'n1' of the object named 's2' (a field in a structure if you wish), and push the result on the stack. See the table below for a list of possible properties (or fields) values. 4
    Set Property 0x23 0
    operation: s3.n2 = a1
    Pop a value from the stack and use it to set the specified named object at the specified field property. See the table below for a list of possible properties (or fields) values. 4
    Duplicate Sprite 0x24 0
    operation: s3 s2 i1 Duplicate
    's3' is the name of a sprite which is copied. The new sprite has the name 's2' and is placed at depth 'i1'. The depth isn't used the same way in Flash 4 and Flash 5. The depth isn't clearly documented anywhere, but it looks like you need to have a depth of 16384 or more for a duplicated sprite to work properly. 4
    Remove Sprite 0x25 0
    operation: s1 Remove
    Pop the string 's1' with the name of the sprite to be removed from view. 4
    Trace 0x26 0
    operation: s1 Trace
    Print out string s1 in debugger output window. Ignored otherwise. 4
    Start Drag 0x27 0
    operation: [n7 n6 n5 n4] b3 b2 s1 StartDrag
    Pop a target name (s1), a first boolean (b2) -- (un)lock the center of the object to the mouse pointer, a second boolean (b3) -- constrained the mouse in the following rectangle (n4 to n7, representing y2, x2, y1, x1 -- NOTE: the rectangle is not defined if (b3) is False). The object will follow the mouse until a Stop Drag is applied or another object is defined as the object to be dragged. 4
    Stop Drag 0x28 0
    operation: StopDrag
    Stop a drag operation. 4
    String Less Than 0x29 0 (b)
    operation: s2 < s1
    Pops two strings, compare them, push the result back on the stack. 4 only?
    Throw 0x2A 0 (a)
    operation: throw a1
    This action pops one item and returns it as an exceptional result. You can catch exceptions using the Try action. 7
    Cast Object 0x2B 0 (o)
    operation: (s2) o1
    The Cast Object action makes sure that the object o1 is an instance of the class s2. If it is the case, then o1 is pushed back onto the stack. Otherwise Null is pushed back onto the stack. The comparison is identical to the one applied by the Instance Of action. 7
    Implements 0x2C 0 (o)
    operation: s1 implements s3, s4 ... sn
    (where n is i2 + 2)
    This action declares an object as a sub-class of one or more interfaces. The number of interfaces has to be indicated by i2. An interface is referenced by its name (which happens to be the same as the constructor function name.) 7
    Random 0x30 0 (i)
    operation: random(n1)
    Pops one number which is the maximum value (not included) that the random() function will return, push the generated value on the stack. 'n1' should not be zero. 4
    String Length
    (multibyte)
    0x31 0 (i)
    operation: wclen(s1)
    Pops one multi-byte string, push it's length in actual character on the stack. 4
    Ord 0x32 0 (i)
    operation: s1[0]
    Pops one string, compute the ASCII value of its first character and put it back on the stack. 4
    Chr 0x33 0 (s)
    operation: i1
    Pops one integer, use it as a ASCII character and push the newly created string on the stack. 4
    Get Timer 0x34 0 (i)
    operation: movie_time()
    Get the current movie timer in milliseconds and push it on the stack. This is equivalent to the number of frames which have been played so far. 4
    SubString
    (multibyte)
    0x35 0 (s)
    operation: s3[i2 .. i2 + i1 - 1]
    Pops a multi-byte string, get i1 characters from the position i2 (1 based) and push the result back on the stack. 4
    Ord
    (multibyte)
    0x36 0 (i)
    operation: s1[0]
    Pops one string, compute the multi-byte value of its first character and put it back on the stack. 4
    Chr
    (multibyte)
    0x37 0 (s)
    operation: i1
    Pops one integer, use it as a multi-byte string character and push the newly created string on the stack. 4
    Delete 0x3A 0
    operation: delete(s1, o2)
    Pops one string which is the name of the property to be deleted. Then pop the object from which the property is to be deleted.

    It is necessary to Push Data type 0x03 before the string as in:

    96 04 00 03 00 'a' 00 3A
    delete("a");

    to delete a global variable.

    5
    Delete All 0x3B 0
    operation: delete(s1, o2)
    Pops one string which is the name of the thread which will get all of its variables deleted. 5
    Set Local Variable 0x3C 0
    operation: s2 = a1
    Pops a value and a variable name. Create or set a local variable of that name with the (initial) value as specified. The same local variable can safely be set in this way multiple times. To only declare a local variable, use the Declare Local Variable instead. 5
    Call Function 0x3D 0 (a)
    operation: s1(i2, [a3, a4, a5...])
    Pops one string which is the name of the function to call, pop one integer which indicates the number of arguments following, pop each argument, call the named function, push the result of the function on the stack. There is always a result. The idea of the concept is that the function being called will use its own stack, however, that's not really the case. In other words, if a function stacks multiple results, they all are returned.

    Flash V5.x offers a set of internal functions available to the end user via this Call Function instruction. Please, see the table below for a complete list of these internal functions.

    5
    Return 0x3E 0 (a)
    operation: return a1
    Pops one object and return it to the caller. The result is stacked on the caller stack, not the stack of the function being executed. 5
    Modulo 0x3F 0 (i)
    operation: i2 % i1
               or
    	   f2 % f1
    Pops two numbers, computes the modulo and push the result back on the stack. 5
    New 0x40 0 (o)
    operation: o = new s1
               o.s1(i2, [a3, a4, a5 ...])
    Pop the class name for the new object to create. Pop the number of arguments. Pop each argument. Create an object of class s1. Call the constructor function (which has the same name as the object class: s1). The result of the constructor is discarded. Push the created object on the stack. The object should then be saved in a variable or object method. 5
    Declare Local Variable 0x41 0
    operation: s1
    Pops a variable name and marks it as a local variable. If the variable doesn't exist yet, then its value is undefined. To declare and set a local variable, use the Set Local Variable instead. 5
    Declare Array 0x42 0 (t)
    operation: new array[i1]
    array[0] = a2
    array[1] = a3
    ...
    array[i1 - 1] = an
    (where n = i1 + 1)
    Pops the number of elements in the array. Pop one value per element and set the corresponding entry in the array. The array is pushed on the stack. It can later be sent to a function or set in a variable. 5
    Declare Object 0x43 0 (o)
    operation: new object
    count = i1
    object.a3 = a2
    object.a5 = a4
    ...
    object.an = am
    (where n = i1 * 2 + 1 and m = i1 * 2)
    Pops the number of members in the object. Pop one value and one name per member and set the corresponding member in the object. The resulting object is pushed on the stack. It can later be sent to a function or set in a variable.

    Note: the member names are converted to strings; they certainly should be strings thought anything is supported.

    5
    Type Of 0x44 0 (s)
    operation: typeof(a1)
    Pops some data, define its type and push the name of its type back on the stack. The currently supported types are as follow:

    number
    boolean
    string
    object
    movieclip
    null
    undefined
    function
    5
    Get Target 0x45 0 (s)
    operation: target_of(o1)
    Pops an object, if it is a valid sprite, push it's path on the stack. A sprite path can be used by different other actions such as the Goto Expression. 5
    Enumerate 0x46 0 (v)
    operation: s1
    Pop the name of a thread (can it only be the root?) and push all of its children (objects & variables) back on the stack. The list is null terminated. 5
    Add
    (typed)
    0x47 0
    (a)
    operation: i2 + i1
    	   or
    	   f2 + f1
    	   or
    	   s2 + s1
    Pops two numbers or two strings, computes the sum or concatenation and push the result back on the stack. 5
    Less Than
    (typed)
    0x48 0 (b)
    operation: i2 < i1
    	   or
    	   f2 < f1
    	   or
    	   s2 < s1
    Pops two integers or two strings, computes whether they are ordered from smaller to larger and push the result back on the stack. 5
    Equal
    (typed)
    0x49 0 (b)
    operation: i2 == i1
            or f2 == f1
            or s2 == s1
    Pops two integers, floats or strings, computes whether they are equal and push the result back on the stack. If a mix of types is found, then convertions occur. Strings may be transformed in numbers and numbers in strings as with the untyped Equal operator. 5
    Number 0x4A 0 (n)
    operation: a1.valueOf()
    Pops one item and transform it into a number. For strings it works as expected (see the strtof(3C) manual pages). For a user defined object, the method named valueOf() is called. 5
    String 0x4B 0 (n)
    operation: a1.toString()
    Pops one item and transform it into a string. For numbers it works as expected (see the sprintf(3C) manual pages). For a user defined object, the method named toString() is called. 5
    Duplicate 0x4C 0 (a1 a1)
    operation: a1
    Pops one item and push it back twice. 5
    Swap 0x4D 0
    (a1 a2)
    operation: a2 <-> a1
    Pops two items and push them back the other way around. 5
    Get Member 0x4E 0 (a)
    operation: o2[a1]
    Pops one string or an integer (member name), pop an object reference, defines the value of that object member and push the result back on the stack. 5
    Set Member 0x4F 0
    operation: o3[a2] = a1
    Pops a value 'a1' which will be the new member value, then one string or integer 'a2' (the name of the member to modified or create), and finally pop an object reference 'o3'. If the member doesn't exists yet, create it. Finally, sets the object member to the value 'a1'. 5
    Increment 0x50 0 (n)
    operation: n1 + 1
    Pops one number, add 1 to it and push it back on the stack. 5
    Decrement 0x51 0 (n)
    operation: n1 - 1
    Pops one number, substract 1 to it and push it back on the stack. 5
    Call Method 0x52 0 (a)
    operation: o2.s1(i3, [a4, a5, a6...])
    or
    o2(i3, [a4, a5, a6...])
    Pops the name of a method (can be the empty string), pop an object, pop the number of arguments, pop each argument, call the method (function) of the object, push the returned value on the stack. 5
    New Method 0x53 0 (o)
    operation: o = new s2
               o.s1(i3, [a4, a5, a6...])
               or
               o.s2(i3, [a4, a5, a6...])
    Pops the name of a method (can be the empty string), pop an object (created with the Declare Object,) pop the number of arguments, pop each argument, create a new object, then call the specified method (function) as the constructor function of the object, push the returned value on the stack. This allows for overloaded constructors as in C++. 5
    Instance Of 0x54 0 (b)
    operation: o2 is_instance_of s1
    Pops the name of a constructor (s1 - ie. "Color") then the name of an object (s2). Checks whether the named object is part of the class defined by the constructor. If so, then true is push on the stack, otherwise false.

    Since SWF version 7, it is possible to cast an object to another using the Cast Object action. This action returns a copy of the object or Null, which in many cases can be much more practical.

    6
    Enumerate Object 0x55 0 (v)
    operation: o1
    Pops an object from the stack, push a null, then push the name of each member on the stack. 6
    And 0x60 0 (i)
    operation: i2 & i1
    Pops two integers, computes the bitwise AND and push the result back on the stack. 5
    Or 0x61 0 (i)
    operation: i2 | i1
    Pops two integers, computes the bitwise OR and push the result back on the stack. 5
    XOr 0x62 0 (i)
    operation: i2 ^ i1
    Pops two integers, computes the bitwise XOR and push the result back on the stack.

    This operator is also used to generate a bitwise NOT with an immediate value of -1.

    5
    Shift Left 0x63 0 (i)
    operation: i2 << i1
    Pops two integers, shift the 2nd one by the number of bits specified by the first integer and push the result back on the stack. 5
    Shift Right 0x64 0 (i)
    operation: i2 >> i1
    Pops two integers, shift the 2nd signed integer by the number of bits specified by the first integer and push the result back on the stack. 5
    Shift Right Unsigned 0x65 0 (i)
    operation: i2 >>> i1
    Pops two integers, shift the 2nd unsigned integer by the number of bits specified by the first integer and push the result back on the stack. 5
    Strict Equal 0x66 0 (b)
    operation: a1 === a2
    Pops two parameters and return whether they are strictly equal. No cast is applied to either s1 or s2. Thus two items of different type are not equal (0 == "0" is true, but 0 === "0" is false.) 6
    Greater Than
    (typed)
    0x67 0 (b)
    operation: a2 > a1
    Similar to Swap + Less Than. It checks whether the second parameter is greater than the first and return the boolean result on the stack. 6
    String Greater Than
    (typed)
    0x68 0 (b)
    operation: s2 > s1
    Similar to Swap + String Less Than. It checks whether the second string is greater than the first and return the boolean result on the stack. 6
    Extends 0x69 0 (o)
    operation: super_class = s1
    sub_class = s2
    sub_class.prototype = new object
    sub_class.prototype.__proto__ = super_class.prototype;
    sub_class.prototype.__constructor__ = super_class;
    The Extends action will be used to define a new object which extends another object. The declaration in a C like action script will be something like:
    class A extends B;
    In an SWF action script, you don't exactly declare objects, you actually instanciate them and define their functions. This action creates a new object named s2 which is an extension of the object s1.

    Use this action whenever you need to inherit an object without calling its constructor.

    7
    Goto Frame 0x81 2
    unsigned short	f_frame_no;
    The playback continues at the specified frame 1
    Get URL 0x83 variable
    string	f_url;
    string	f_target;
    Load the specified URL in the specified target window.

    When the target is set as "_level0", the current SWF file is replaced by the file specified in the f_url field. The name in the f_url field should be a proper SWF file or the area will simply become black.

    When the target is set as "_level1", something special is supposed to happen. I still don't know what it is...
    Also the effect of _level1 + an empty URL is ... (?)

    The target can also be set to the regular HTML names such as "_top" or a frame name.

    1
    Store Register 0x87 1 (a)
    unsigned char	f_register;
    
    operation: regs[f_register] = a1

    Pop one value from the stack, push it back on the stack and also store it in one of four or 256 registers which number is specified in the tag (0, 1, 2 or 3 only if not in a Declare Function (V7). I tried other numbers and they don't work in SWF version 6 or older.) Until set a register has the value undefined. The value of a register can be retrieved with a Push Data action and the register type with the matching register number.

    (To be tested) It is likely that trying to read a register which is not legal in a Declare Function (V7) will generate an exception (Yes! A Throw!) but I wouldn't be surprised if you just get undefined.

    5
    Declare Dictionary 0x88 variable
    (s)
    unsigned short	f_count;
    string		f_dictionary[f_count];
    Declare an array of strings which can later be retrieved using the Push Data action with a dictionary lookup. There can be a maximum of 65534 strings. The visibility of a dictionary is within its DoAction or other similar block of actions. 5
    Wait For Frame 0x8A 3
    unsigned short	f_frame;
    unsigned char	f_skip;
    Wait until the frame specified in f_frame is fully loaded to execute actions right after this one. Otherwise skip the specified number of actions. This is usually used with a Goto Frame like in:
    Next Frame
    Wait for Frame #10
      (otherwise skip 1 action)
    Goto Frame #5
    Play
    End
    
    This will usually be used to display some Loading... info before the complete movie is loaded.
    1
    Set Target 0x8B variable
    string	f_target;
    If the string f_target is the empty string, then the next actions apply to the main movie. Otherwise it is the name of a sprite and the followings actions apply to that sprite only. 1
    Goto Label 0x8C variable
    string	f_label;
    Go to a named frame. Frames are given names with the use of the FrameLabel tag. 3
    Wait For Frame
    (dynamic)
    0x8D 1
    unsigned char	f_skip;
    
    operation: a1 WaitForFrame
    Pop a value or a string used as the frame number to wait for. The frame can be specified as with the Goto Expression. If the frame was not reached yet, skip the following f_skip actions 4
    Declare Function (V7)
    (with 256 registers)
    0x8E variable
    string		f_name;
    unsigned short	f_arg_count;
    unsigned char	f_reg_count;
    unsigned short	f_declare_function2_reserved : 7;
    unsigned short	f_preload_global : 1;
    unsigned short	f_preload_parent : 1;
    unsigned short	f_preload_root : 1;
    unsigned short	f_suppress_super : 1;
    unsigned short	f_preload_super : 1;
    unsigned short	f_suppress_arguments : 1;
    unsigned short	f_preload_arguments : 1;
    unsigned short	f_suppress_this : 1;
    unsigned short	f_preload_this : 1;
    swf_params	f_params[f_arg_count];
    unsigned short	f_function_length;

    WARNING: the preload/suppress flags are defined on a short and thus the bytes in a Flash file will look swapped.

    Declare a function which can later be called with the Call Function action. The f_function_length defines the number of bytes that the function declaration takes. All the actions included in this block are part of the function body.

    A function should terminate with a Return action. The value used by the return statement will be the only value left on the caller stack. Functions declared with this action code byte also support the use of up to 255 local registers. To access the local registers, use the Push Data action and to change a register value use the Store Register action.

    Do not terminate a function with an End action

    Also, it is possible to control the preloading or suppressing of the different internal variables: this, arguments, super, _root, _parent and _global. All the function arguments can also be ignored. If you write a compiler, you should preload only the variables which are used in the function body. And you should suppress all the variables which are never being accessed in the function body [WARNING: note that it is possible to concatenate two strings such as "th" and "is" to generate the name "this" and then do a 'get that variable'. This means a function can't really know whether any of the internal variables are really never going to be used... but who writes code like that, really?!]. If you are writing a smart player, then you may want to avoid creating the variables until they are actually being used (thus when an if() statement ends the function prematurly, you may end up not creating many of these variables!).

    The preloading bits indicate in which register to load the given internal variable. The suppressing bits indicate which internal variable not to create at all. That is, if the preloading bit is not set and the suppressing is not set, then the internal variable are supposed to be created by name (i.e. you can access a variable named "this" from within the function when bits 0 and 1 are zero).

    The f_reg_count parameter needs to be specified and it tells the player the largest register number in use in this function. This way it can allocate up to 255 registers on entry. By default, these registers are initialized as undefined. The variables automatically loaded in registers are loaded starting at register 1. The internal variables are loaded in this order: this, arguments, super, _root, _parent and _global. Thus, if you call a function which accepts three user parameters and wants this and _parent, it will load this in register 1, _parent in register 2 and the user parameters can be loaded in registers 3, 4 and 5. User parameters are loaded in registers only if their corresponding f_param_register field is not zero (see swf_params). Also, they don't need to be defined in order.

    Note that system variables are loaded AFTER arguments. This means if you put an argument in register 3 and this register is also used for _root, then within the function the register 3 will be equal to the content of _root. Compilers should never do that though.

    7
    Try 0x8F variable
    unsigned char	f_try_reserved : 5;
    unsigned char	f_catch_in_register : 1;
    unsigned char	f_finally : 1;
    unsigned char	f_catch : 1;
    unsigned short	f_try_size;
    unsigned short	f_catch_size;
    unsigned short	f_finally_size;
    if(f_catch_in_register == 0) {
    	string		f_catch_name;
    }
    else {
    	unsigned char	f_catch_register;
    }
    Declare a try/catch/finally block.

    This has the behavior of the action script:

    	try { ... }
    	catch(name) { ... }
    	finally { ... }

    At this time, there is no definition of exception in the action scripts. But you can write a function which Throws.

    The sementic of the try/catch/finally block is very well defined in ECMA 262 version 3 (see pages 87/88).

    The f_finally and f_catch may not both be null or the sementic of the try block would be wrong. The f_try_size, f_catch_size and f_finally_size are defined in bytes and give the size of each of the block of instructions just like a function definition.

    Do not terminate these blocks with an End action

    If the f_catch_in_register is set to 1, then a register number is specified instead of a variable name. This will usually be faster.

    7
    With 0x94 0
    unsigned short	f_size;
    
    operation: with o1
    The variable references within the following f_size bytes are taken as names of members of the specified object 'o1'. When no member is available in that object, the previous With, or the corresponding global variable is queried. This is similar to the Pascal language with instruction or a Set Target (dynamic). Note that the number of With within other With is limited to 7 (a depth of 8 is hard coded for some reasons...). Additional With blocks are ignored. The size defines up to where the With has an effect (the f_size is taken as a branchment offset except that it is always positive). Note that it is to the creator of the action scripts to ensure the proper nesting of each With. 5
    Push Data 0x96 variable
    struct {
    	unsigned char	f_type;
    	...		f_data;
    } f_push_data[<variable>];
    
    Push some immediate data on the stack. This action was introduced in V4.0. The supported data types vary depending on the version of player that you have. As many values as necessary can be pushed at once. The f_push_data structure will be repeated multiple times as required. For instance, to push two strings on the stack at once, you would use the following code:
    96
    0C 00
    00 't' 'e' 's' 't' 00
    00 'm' 'o' 'r' 'e' 00

    Please, see the table of data types below for more information.

    variable
    Branch Always 0x99 2
    signed short	f_offset;*
    Jump to the specified instruction. 4
    Get URL2 0x9A 1
    unsigned char	f_method;
    
    operation: s1 s2

    Pop two strings, the URL and the window Name. Use f_method to know how whether variables in the current SWF context should also be forwarded to the destination page (this means you can create dynamic forms with full HTML conformance). It seems that in V4.x (or would it be in V6.x?!? - it doesn't seem to work in V5.x) you could use URL2 to read a text file (with a .txt extension) with a list of variables using something like this:

    Push URL "myvars.txt"; Target "_level0"; Get URL2;

    The syntax of the file myvars.txt is a list of lines which are defined as a variable name followed by an equal sign and its contents. If you have more than one line, start the following lines with an ampersand.

    f_methodAction
    0<don't send variables>
    1GET
    2POST
    4
    Declare Function 0x9B variable
    string		f_name;
    unsigned short	f_arg_count;
    string		f_arg_name[f_arg_count];
    unsigned short	f_function_length;
    Declare a function which can later be called with the Call Function action. The f_function_length defines the number of bytes that the function declaration takes. All the actions included in this block are part of the function. A function should terminate with a Return action. The value used by the return statement should be the only value left on the caller stack.

    Do not terminate a function with an End action

    Prior version 6, the Macromedia player would keep all the data pushed in a function as is when the function returned whether there is a return statement or not.

    Since version 7, it is preferable to use the new type of functions: Declare Function (V7).

    5
    Branch If True 0x9D 2
    signed short	f_offset;*
    
    operation: b1
    Pop a boolean value; if true then jump to the specified instruction; otherwise continue with the following instructions. 4
    Call Frame 0x9E 0
    nothing
    (this is a bug known by Macromedia)
    
    operation: s1
    Pop a string or integer and call the corresponding frame. This means: (1) search the corresponding frame, (2) execute its actions and (3) continue with the action defined after this one. The frame can be identified with a name or a number. It is also possible to specify a target movie ("<sprite name>.<frame name>? - to be tested...) 4
    Goto Expression 0x9F 2
    unsigned char	f_play;
    
    operation: a1
    Pop a value or a string and jump to the specified frame. When a string is specified, it can include a path to a sprite as in:
    /Test:55
    When f_play is ON, the action is to play as soon as that frame is reached. Otherwise, the frame is shown in stop mode.
    4

    ID Name Data Comments Version
    0x00 String
    string	f_string
    Push a string on the stack 4
    0x01 Float
    (32 bits)
    float	f_float;
    Push a 32 bits IEEE floating point value on the stack. This type can be used to specify a Property reference. Note that the property reference will be saved as a floating point value though only the integral part will be used. 4
    0x02 NULL <none> Push a NULL on the stack (0?). 5
    0x03 Undefined <none> Push an undefined object on the stack. This is not a string, integer, float or boolean. It simply is an undefined element. Any operation on an undefined element yields undefined except an equal comparison (and some operations such as a Pop). 5
    0x04 Register
    unsigned char	f_register;
    Push the content of the given register on the stack. You have only 4 registers available in SWF (number 0, 1, 2 and 3). Since version 7 of SWF, it is possible to use up to 256 registers in a Declare Function (V7). However, outside such a function, the limit is the same. To set a register, use the Store Register action. 5
    0x05 Boolean
    unsigned char	f_boolean;
    Push a boolean value on the stack (f_boolean needs to be 0 or 1). 5
    0x06 Double
    (64 bits)
    unsigned char	f_value[8];
    An IEEE double value saved in a strange way. The following gives you the C code used to read these double values.
    double	result;
    char	value[8];
    
    value[4] = ReadByte(input_stream);
    value[5] = ReadByte(input_stream);
    value[6] = ReadByte(input_stream);
    value[7] = ReadByte(input_stream);
    value[0] = ReadByte(input_stream);
    value[1] = ReadByte(input_stream);
    value[2] = ReadByte(input_stream);
    value[3] = ReadByte(input_stream);
    
    result = * (double *) value;
    
    5
    0x07 Integer
    unsigned long	f_integer;
    Push an integer on the stack. 5
    0x08 Dictionary Lookup
    unsigned char	f_reference;
    Push a string as declared with a Declare Dictionary. The very first string in a dictionary has reference 0. There can only be up to 256 strings push with this instruction. 5
    0x09 Large Dictionary Lookup
    unsigned short	f_reference;
    Push a string as declared with a Declare Dictionary action. The very first string in a dictionary has reference 0. There can be up to 65534 strings pushed this way. Note that the strings 0 to 255 should use the type 0x08 instead. 5
    Color Object
    Function Prototype Comments Version
    Color(sprite target)
    When you create a color object you need to specify the target to which the color changes (or retrieval) will be applied. 5
    integer getRGB()
    Retrieve the RGB color from the color object. The color format is 0xRRGGBB. 5
    colorTransformObject
    	getTransform()
    Returns a transform object representing the current color transformation applied to the object. This object is composed of eitght members (ra, rb, ga, gb, ba, bb, aa, ab). One for each component (rgba) divided in two sets: scaling factor ra, ga, etc. -- a value from -100 to +100; and an offset rb, gb, etc. -- a value from -255 to +255. 5
    void setRGB(integer new_color)
    Changes the color of the object attached to this color object. The color format is 0xRRGGBB. 5
    void setTransform(
    	colorTransformObject
    		color_transform)
    Changes the colors in the transformation matrix of the attached object. Please see the getTransform() for more information about the colorTransformObject. 5



    Math Object
    Function Prototype Comments Version
    double abs(double x);
    Returns the absolute value of x 5
    double acos(double x);
    Returns the arc cosine of x 5
    double asin(double x);
    Returns the arc sine of x 5
    double atan(double x);
    Returns the arc tangent of x 5
    double atan2(double y, double x);
    Returns the arc tangent of y / x 5
    double ceil(double x);
    Returns the ceiling value of x, that is, find a value y which is an integer greater than or equal to x 5
    double cos(double x);
    Returns the cosine of x which should be a radian angle 5
    double exp(double x);
    Returns the neperian exponential of x (e power x) 5
    double floor(double x);
    Returns the floor value of x, that is, find a value y which is an integer smaller than or equal to x 5
    double log(double x);
    Returns the neperian logarithm of x (the value of y in x = e power y) 5
    double max(double x, double y);
    Returns x or y, whichever is the largest value 5
    double min(double x, double y);
    Returns x or y, whichever is the smallest value 5
    double pow(double x, double y);
    Returns x power y 5
    double random();
    Returns a random value which lies between 0.0 and 1.0 (1.0 included? -- to be confirmed) 5
    double round(double x);
    Returns the integer closest to x 5
    double sin(double x);
    Returns the sine of x which should be a radian angle 5
    double sqrt(double x);
    Returns the square root of x 5
    double tan(double x);
    Returns the tangent of x which shuold be a radian angle 5
    Constant Definitions Comments Version
    double e;
    Returns the value of e (about 2.7182818284590452354) 5
    double ln2;
    Returns the value of log(2) (about 0.69314718055994530942) 5
    double log2e;
    Returns the value of log2(e) (about 1.4426950408889634074) 5
    double ln10;
    Returns the value of log(10) (about 2.30258509299404568402) 5
    double log10e;
    Returns the value of log10(e) (about 0.43429448190325182765) 5
    double pi;
    Returns the value of pi (about 3.14159265358979323846) 5
    double sqrt1_2;
    Returns the value of sqrt(0.5) (about 0.7071067811865475244) 5
    double sqrt2;
    Returns the value of sqrt(2) (about 1.4142135623730950488) 5



    String Object
    Function Prototype Comments Version
    string charAt(int index);
    Returns a string composed of the character at the position defined by the index. The first character is at position 0. The last character is at position string.length - 1. 5
    integer charCodeAt(int index);
    Returns the code of the character at the position defined by index. The first character is at position 0. The last character is at position string.length - 1. 5
    string concat
      (string s1 [, string s2 [, ...]]);
    Concatenate each string (this, s1, s2, etc.) in one and return the result. The parameters will automatically be converted to strings if necessary. Note that floating point values will usually be written with great precision (i.e. 0.33 will appear as 0.33000001311302) 5
    string fromCharCode
      (int c1 [, int c2 [, ...]]);
    WARNING: I tried to make this function work, it only returns an empty string. If you can make sense of it, please let me know how you're using it! (this is with a V5.x plug in)

    Create a string composed of each of the specified characters (c1, c2, etc.). Each value must represent a valid 16-bit character code (1 to 65535).

    5
    int indexOf(string s [, int start]);
    Returns the first index at which s is found within the string object. When start is specified, the search begins at that position (inclusive) instead of the first character (by default start is assumed to be zero). If s isn't found, -1 is returned instead of a valid position. The first character is at position 0 and the last at string.length - 1. 5
    int lastIndexOf
      (string s [, int start]);
    Returns the last index at which s is found within the string object. When start is specified, the search begins at that position (inclusive) instead of the last character. Watch out, the search goes backward thus the start is actually the last character of this string which is tested. If s isn't found, -1 is returned instead of a position. 5
    string slice(int start [, int end]);
    Returns a string composed of the characters of this string starting at the position start and ending at position end - 1 inclusive. When the end parameter isn't specified, it is automatically given the position of the last character. It is possible to use negative values for both parameters. Negative values give a position from the last character of the string rather than the first. -1 represents the last character of the string, -2 the one before the last, etc.

    When the resulting start position is larger or equal to the end position, then an empty string is returned. The following gives you the equation to test whether the start and end parameter are valid or if an empty string should be returned.

    if((start < 0 ? start + string.length
                  : start)
    >= (end   < 0 ? end + string.length
                  : end)) {
        return "";
    }
    /* else compute the result */
    (See the substr for a function used with a position and length instead of two positions)
    5
    array split([string delimiter]);
    Returns the string split in an array of strings. The delimiter determines where the string will be cut (the delimiters are removed from the source string). When no or an empty delimiter is specified, the string as a whole is saved in the array as the 1st item. Otherwise, the delimiter is searched and each instance represents a string separation.

    NOTE: An empty string delimiter supposedly means that each character of the input string is saved in the array as strings (See the Macromedia website fromCharCode). I tried and it looks like the empty string or no delimiter cases are both working alike as described above.

    5
    string substr
      (int start [, int length]);
    Returns a string composed of the characters of this string starting at the position start and ending at position start + length - 1 inclusive. When the length parameter isn't specified, it is automatically given the necessary value so the end of the string is fully included. It is possible to use negative values for the start parameter in which case it references a position starting at the end of the string. The position -1 represents the last character of the string. If length is small or equal to zero (length <= 0) then an empty string is returned. (See the slice for a function used with two positions instead of a position and length and the substring method for out of order indices). 5
    string substring
      (int p1 [, int p2]);
    Returns a string composed of the characters of this string starting at the position start and ending at position end - 1 inclusive. This function doesn't support negative positions. The start and end positions are defined as:
    cp1 = p1 < 0 ? 0 : p1;
    cp2 = p2 < 0 ? 0 : p2;
    start = cp1 < cp2 ? cp1 : cp2
    end = cp2 > cp1 ? cp2 : cp1
    (See also the slice and substr methods).
    5
    string toLowerCase();
    Returns a string which is like the input string except for all uppercase characters are first swapped for their corresponding lowercase characters. 5
    string toUpperCase();
    Returns a string which is like the input string except for all lowercase characters are first swapped for their corresponding uppercase characters. 5
    Constant Definitions Comments Version
    int length;
    Returns the length of the string in characters. 5








    Common Structures





    Appendix A. the geometry in SWF





    History of this reference

    This document was last modified on Sep 10 2005.