ActionScript Specifications

(Unofficial specs by Olivier Debon)
Version 0.5 - August,1,1999
1999-8-1:   New entry thanks to Jason Schuchert: waitFOrFrameExpression.
1999-7-27: New entry: GetUrl2.
1999-7-25: New entries thanks to Jason Schuchert: setTargetExpression, Trace and GotoExpression.
This page aims at describing the Action Codes added in Flash 4 format. These specifications are unofficial and are based on a personal work. Parts of this document are assumptions.

The language is based on a stack oriented engine. Data are pushed onto the stack and operators pop data, process them and push the result (if any) onto the stack. This is close to languages like RPN (Reverse Polish Notation) and Forth (like PostScript ...). Data and operators (or functions) are encoded using the same way Flash 3 codes are.
Processing is done sequentially. Instructions include Branch actions (i.e Gotos), the engine uses the address of each instructions so as to know where to branch. Branch actions have an offset operand that indicates the relative displacement from where the engine is (using a PC, Program Counter) to the instruction to jump to. Therefore, there are positive and negative offsets. The PC equals the next instruction address when executing a current instruction.

All instructions are encoded as ACTION RECORDs, see the Flash File Reference from Macromedia.
The first field is a UI8 (Unsigned Integer 8 bit value) that represents the instruction code.
If the 8th upper bit is set, the code field is always followed by a length field (UI16), then come the data.
If the 8th upper bit is not set, the parser must proceed to next action (no parameters are given).

Before describing the operators and functions, here the encoding of how to push data onto the stack. There are two types of operands.

The first type is a simple string data, actually all type of data are string defined (even numerical values). The True value is "1" and the False value is "0". The NewLine value is "\n".

The second type of operand is property. This is a special type. Most of the time it pushes onto the stack the current property reference. GetProperty is convenient to specify a target from which the user wants to know a peculiar property value.

So to push data onto the stack:
Field Type Comment
PushData UI8 Action=0x96
Length UI16 Length of following data
DataType UI8 00=string
If (DataType == 00)
String UI8[] Null terminated string.
If (DataType == 01)
Unknown UI16 Always 0000
PropertyID UI16 0000 = X
3F80 = Y
4000 = Xscale
4040 = Yscale
40C0 = Alpha
40E0 = Visibility
4120 = Rotation
4140 = Name
4180 = Highquality
4188 = ShowFocusRectangle
4190 = SoundBufferTime
4680 = WTHIT

The stack operation column describes the operands on the stack before the operator and the result on the stack after the instruction processing:

operand operand ... operand Operator result result

Some operators have arguments encoded in the same action-record (like in Flash 3), in this case the operator's notation becomes: Operator(arguments). And this special encodings are described later.
Definition Stack Operation Code Comment
Add (+) n1 n2 + n 0A  
Substract (-) n1 n2 - n 0B  
Multiply (x) n1 n2 x n 0C  
Divide (/) n1 n2 / n 0D  
Equal (=) n1 n2 = bool 0E  
Less Than (<) op1 op2 < bool 0F  
Logical And bool1 bool2 and bool 10  
Logical Or bool1 bool2 or bool 11  
Logical Not bool not bool 12  
String Equal (eq) str1 str2 eq bool 13  
String Length (Length) string Length n 14  
String Extraction (Substring) string index count Substring string 15  
Int num Int num 18  
Eval varname Eval value 1C Returns the content of the given variable name.
SetVariable varname value Set 1D Produces nothing on stack.
SetTargetExpression expression SetTargetExpression 20 Like TellTarget but uses current value on stack.
String Concatenation (&) str1 str2 & string 21  
GetProperty target property GetProperty value 22 See GetProperty table for property value.
SetProperty target propertyID value SetProperty 23 Caution: see PropertyID definition above.
Duplicate Clip target new depth Duplicate 24 Depth is not the depth parameter typed in Flash 4. See Duplicate Clip note in Comments section.
Remove Clip target RemoveClip 25  
Trace Trace 26 For debugging purpose.
StartDragMovie target [ left top right bottom ] constraint lock StartDrag 27 If lock is True then lockMouse. If constraint is True the optional parameters must be present on the stack, otherwise they must be removed.
StopDragMovie StopDragMovie 28 No operand, no result.
String Comparison (lt) str1 str2 lt bool 29  
Random seed random num 30 Seed is a numerical value.
MBLength string MBLength num 31  
Ord string Ord num 32  
Chr num Chr string 33 Only first character in string.
GetTimer GetTimer num 34  
MBSubString string index count MBSubString string 35  
MBOrd string MBOrd num 36  
MBChr num MBChr string 37  
waitForFrameExpression expression waitForFrameExpression 8D  
BranchAlways BranchAlways(offset) 99 See encoding below.
GetURL2 url window GetURL2(post/get) 9A See encoding below.
BranchIfTrue bool BranchIfTrue(offset) 9D See encoding below.
CallFrame target CallFrame 9E  
GotoExpression expression GotoExpression(stop/play) 9F Like Goto but uses current value on stack.
All other codes from Flash 3 are still valid, of course.

Here is the encoding of some special instructions:
Field Type Comment
GetURL2 UI8 Action=0x9A
Length UI16 Always 1
Method UI8 00=Don't Send

Field Type Comment
BranchAlways UI8 Action=0x99
Length UI16 Always 2
Offset UI16 Relative offset to the instruction address to jump to.

Field Type Comment
BranchIfTrue UI8 Action=0x9D
Length UI16 Always 2
Offset UI16 Relative offset to the instruction address to jump to if needed.

The GetProperty instruction takes a property operand which a numerical value that represents a corresponding property. Here is the table:
Property Numerical Value


Comparing to instructions that are available in the Flash4 tool, it seems that some are missing here. Actually, there are redundant operations in the tool that can be a combination of basic instructions. For example the GreaterThan operator is achieved by swapping the operands. Another example, the GreaterOrEqualThan operator is just a LessThan followed by a Not. This is just a matter of logical operations.
There is no While instruction, since it can be implemented with tests and conditional Branch.

There is a certain inconsistency for Properties specifications (Get and Set).

The Duplicate Clip instruction is achieved by adding to the desired depth the special WTHIT property. So it looks like:
"target" "new" depth _WTHIT+DuplicateClip.

WTHIT: What The Hell Is This.

Flash is a trademark of Macromedia Inc.