|
ScriptSWF Reference
Check out our high quality products, exclusively for developers!
| Last updated on Jun 23 2008 |
Reference to the Scripting language for SWF
(Written by Alexis Wilke in 2002-2008)
Contents
Appendices
This project license
The entire SSWF project is covered with the MIT license as follow:
Copyright (c) 2002-2008 Made to Order Software Corp.
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.
|
|
About this language
I created this language following a search on the Internet for a
good tool to create SWF files (Flash animations for the internet).
I couldn't find anything of value so I decided I had to create my
own library and a set of tools in order to cope with the lack of
free software in that area.
The idea of a script language is simple since the SWF files are
sequences of rather simple events. It is obvious, when looking in
depth in the SWF file format that it is often necessary to do
repeatitive things which are better handled with a set of loops
rather than a long list of tags. It can easilly be generated by
a graphical tool, though it isn't automatically easy for an end
user to say precisely what he wants when he needs to use dialogs.
This being said, the use of the scripting language isn't necessary.
It is possible to only use the sswf library to create your
own graphical interface.
Alexis Wilke
the author
Language Instructions & Syntax
Though the lexical and grammar tell
you how you can write a script, it doesn't tell you what is legal.
This chapter defines each possible entry as they can be written.
It only describes the SSWF objects since expressions are very much like
C expressions (I suppose you can find such documentation elsewhere.) Note
that there are more expressions in SSWF than in C and handling the
different types is slightly different. This is all explained in the chapter
about the SSWF grammar for those who want to be on the
edge.
The scripting language accepts two types of definitions: variables and objects.
In SSWF, setting a variable is as follow:
variable name = value;
Note that the assignment operator := is also accepted.
Objects are defined by specifying:
- the type of the object (such as
COLOR or
SPRITE);
- an optional1 name (written between quotes);
- and an optional1 list of parameters and definitions compositing
the object (written between curvly brackets.)
1 Some objects must always be named or have a certain number of parameters.
Though the grammar defines object names and parameters as optional, this is not always
true.
For instance, the following code defines the color named White :
color "White" { 255, 255, 255; };
The following table describes all the objects currently accepted by the
SSWF compiler. The descriptions include all the possible fields that an object
accepts.
Different objects have different flags defined below their name. These
flags are described in the following list:
- [nothing] — objects which don't have any specific flags
are expected to either be empty or have only direct parameters;
a direct parameter is a possibly labelled value appearing in
the list of parameters;
- direct — a tag which takes no parameter
- composed — composed objects can include other objects
in their list of parameters;
- semi-composed — composed of objects and direct entries
- ordered — the list of parameters of this object must
be defined in the final expected order; a few objects also are
mostly ordered meaning that some of there parameters can
appear anywhere;
- must be direct — you can't declare such an object in
a list and then name the list to include that object somewhere else;
- must be named — this object always require a name; an
error will occur if no name is specified;
- This is an action — because some actions are composed of
sub-actions, these are defined as objects; this includes actions
such as FUNCTION.
In the table below, optional parameters are written between square brackets
([ and ]). Expressions which can be repeated are defined between curvely
brackets ({ and }). Lists of repeated expressions can be empty. Multiple
items in a list have to be seperated by semi-colons.
The SSWF Objects
| Object |
Fields |
SWF Version |
ACTION (must be direct and also always be named) |
Important note: we now support the
ACTION SCRIPT
object which is accepting action scripts written in
Javascript. In general, it will be a lot easier to use.
The main problem for you will be to test whether the
version being used is what you wanted.
Note: Please, check out the
Alexis' SWF reference
for more info about the versions of the actions.
Defines one action. Actions will be included in a
DO ACTION, a
BUTTON object and since
version 6, some other objects such as a sprite initialization
script.
[ expr [ { ',' expr } ] ]
The action expressions depend on the action.
Note that an action is determined by the name given right after the action
keyword. Actions with the same name can be included multiple times in the
same list.
Some actions don't accept any expression (such as the actions START
and STOP).
Example:
ACTION "GOTO" { "ShowFunkyButtons" };
In order to adhere to a better script standard, Macromedia decided
to add some new arthmetic and comparison instructions. These new instructions won't
change the type of the parameters involved unless otherwise necessary (if you compare
an integer with a string, then (a) if the string can be transformed in a value, compare
two values otherwise (b) the integer is first transformed in a string and a string
comparison is done).
The older instructions still work as before. These always try to cast strings in
integer or floating point values before arthmetic and comparison operations.
The result may not always be the one expected ("1" + "2" is
"12" with the new operator and "3" with the
old one). To help distinguish among both sets of instructions, this scripting
language uses CAST at the end of such instructions
(see the ADD CAST
for instance). When the CAST is present the old instruction
is used.
In the following list, you will find action names with spaces.
Any of these names can be written with no separator, a space ( ), an underscore (_),
a period (.) or a dash (-). For instance, all of the following are valid for a
branch always action:
BRANCHALWAYS, BRANCH ALWAYS, BRANCH_ALWAYS, BRANCH.ALWAYS, BRANCH-ALWAYS.
A few actions are defined as objects because they can include other actions.
These objects are listed here:
Finally, instructions can be included in lists and sub-lists as
required.
| Action |
Accepted Expressions |
| ADD [CAST] |
<none>
|
| AND |
<none>
|
| BRANCH [ALWAYS] |
[ LABEL | GOTO ':' ] expr
Expect a string representing the name
of a label within the list of actions. When this action
is reached, the flow of actions continues at the action
following the given label. (IMPORTANT: this is not a
frame label but an action script label)
|
| [BRANCH] IF TRUE |
[ LABEL | GOTO ':' ] expr
Expect a string representing the name
of a label within the list of actions. When this action
is reached, the flow of actions continues at the action
following the given label if the expression on the stack
represents true. (IMPORTANT: this is not a
frame label but an action script label)
|
| CALL FUNCTION |
<none>
|
| CALL METHOD |
<none>
|
| CAST OBJECT |
<none>
|
| CATCH |
This is a direct instruction: CATCH.
|
| CHR |
<none>
|
| CONCATENATE [STRING] |
<none>
|
| CONSTANT POOL |
{ [ STRING ':' ] expr }
This is a synonym for the DICTIONARY
action. It seems to be more sensical to use CONSTANT
POOL rather than DICTIONARY for a constant
pool.
|
| DECLARE ARRAY |
<none>
|
| DECLARE LOCAL VARIABLE |
<none>
|
| DECLARE OBJECT |
<none>
|
| DECREMENT |
<none>
|
| DELETE |
<none>
|
| DICTIONARY |
{ [ STRING ':' ] expr }
Defines a dictionary for this DoAction or Button context.
Note that since version 1.6.2, SSWF accepts CONSTANT POOL
instead.
|
| DIVIDE |
<none>
|
| DUPLICATE |
<none>
|
| DUPLICATE SPRITE |
<none>
|
| ENUMERATE |
<none>
|
| EQUAL [CAST] |
<none>
|
| EXTENDS |
<none>
|
| FINALLY |
This is a direct instruction: FINALLY.
|
| FUNCTION |
This is a direct instruction: FUNCTION.
|
| GET MEMBER |
<none>
|
| GET PROPERTY |
<none>
|
| GET TARGET |
<none>
|
| GET TIMER |
<none>
|
| GET VARIABLE |
<none>
|
GOTO
GOTO EXPRESSION
GOTO FRAME
GOTO LABEL |
[ [ FRAME ':' ] expr ]
[ [ PLAY ':' ] true | false ]
Expect nothing or a string representing the name
of the frame to go to and a flag to tell whether you want the
movie to continue to playback. Though a name is given, the script
will transform it into a frame number (shorter form of the
GOTO instruction) whenever possible.
When no name is specified, then it encodes the GOTO
with the dynamic form. i.e. the name is expected on the stack.
See the LABEL
instruction for more information.
The GOTO by itself can be used
so the script language uses the most appropriate form available.
Using one of the other forms forces the system
to use that specific form of the goto (except if one doesn't specify
a name in which case the GOTO EXPRESSION is
always used).
The only way to make sure you are using a
GOTO LABEL is to use that form of the action.
|
| IF TRUE |
Please see BRANCH IF TRUE.
|
| IMPLEMENTS |
<none>
|
| INCREMENT |
<none>
|
INT
INTEGRAL PART |
<none>
|
| LABEL |
This is a direct instruction: LABEL.
|
| LESS THAN [CAST] |
<none>
|
| LOGICAL AND |
<none>
|
| LOGICAL NOT |
<none>
|
| LOGICAL OR |
<none>
|
| MB CHR |
<none>
|
| MB ORD |
<none>
|
| MB STRING LENGTH |
<none>
|
| MODULO |
<none>
|
| MULTIPLY |
<none>
|
| NEW |
<none>
|
| NEW METHOD |
<none>
|
| NEXT FRAME |
<none>
|
| NUMBER |
<none>
|
| OR |
<none>
|
| ORD |
<none>
|
| PLAY |
<none>
|
| POP |
<none>
|
| PREVIOUS FRAME |
<none>
|
| PUSH DATA |
[ { BOOLEAN ':' expr } ]
[ { DOUBLE ':' expr } ]
[ { FLOAT ':' expr } ]
[ { INTEGER ':' expr } ]
[ { LOOKUP ':' expr } ]
[ { NULL ':' expr } ]
[ { PROPERTY ':' expr } ]
[ { REGISTER ':' expr } ]
[ { STRING ':' expr } ]
[ { UNDEFINED ':' expr } ]
In a script it is often necessary to use constant values.
These are pushed onto the stack using the PUSH DATA
instruction. The type of the data being pushed needs to be specified. Note
that you can specify as many constant entries as you need in one go. The
following gives you a list of the available data types in ActionScript
and what you can use in SSWF:
- BOOLEAN - expects true or false
- DOUBLE - expects a value
- FLOAT - expects a value
- INTEGER - expects a value; a floating point is rounded to the nearest value
- LOOKUP - expects the index in the current dictionnary
- NULL - anything; the expression is ignored
- PROPERTY - expects a string with the name of the
property to be modified; the names can start by and include spaces ( ),
underscores (_), periods (.) and it can include dashes (-); the names are
listed below:
- X - horizontal position of the object
- Y - vertical position of the object
- X SCALE - horizontal scaling percent of the object
- Y SCALE - vertical scaling percent of the object
- CURRENT FRAME - returns the current frame
- NUMBER OF FRAMES - returns the total number of frames
- ALPHA - the alpha level of the object
- VISIBILITY - whether the object is visible (true or false)
- WIDTH - the width in pixels of the object
- HEIGHT - the height in pixels of the object
- ROTATION - the angle of rotation in degree, clockwise from 12 o'clock
- TARGET - returns the full path to the object as a target name
- FRAMES LOADED - the number of frames already loaded
- NAME - the name of the object
- DROP TARGET - path to an object where this object was dropped
- URL - the URL of this movie
- HIGH QUALITY - whether the movie (or an object) is running in high quality
- SHOW FOCUS RECTANGLE - whether the current button with the focus is shown with a rectangle drawn around it
- SOUND BUFFER TIME - the clock on the currently playing sound(s)
- QUALITY - low, medium or high quality mode
- X MOUSE - horizontal position of the mouse pointer within the movie
- Y MOUSE - vertical position of the mouse pointer within the movie
- WTHIT - I'm not sure what this is for, it seems it is in link with
sprites and their depth (WTHIT = What The Hell Is This?!?)
- REGISTER - place on the stack the value currently saved in the specified register;
there are four registers 0, 1, 2 and 3 only
- STRING - expects a string, including an empty string
- UNDEFINED - expects anything; the expression is ignored;
a special undefined object will be pushed on the stack,
useful to test whether a result is valid or not
|
| RANDOM |
<none>
|
| REMOVE SPRITE |
<none>
|
| RETURN |
<none>
|
| SET LOCAL VARIABLE |
<none>
|
| SET MEMBER |
<none>
|
| SET PROPERTY |
<none>
|
| SET TARGET |
[ [ TARGET ':' ] expr ]
Define the target to use for the following
instruction. The expression usually is the name of a sprite
which will be activated in some ways. When no expression is
specified, the name of the target will be taken from the stack
isntead. It is also possible to do a set target with an empty
string. This resets the target to the main (root) stream of
the movie. (as if the main movie was a sprite with an empty
name).
|
| SET VARIABLE |
<none>
|
SHL
SHIFT LEFT |
<none>
|
[U]SHR
SHIFT RIGHT [UNSIGNED] |
<none>
|
| START |
<none>
Note that it is a good idea to add a START within the very first
frame especially if you have a stop at the end of your movie. This is because
this way a rewind will also automatically restart the movie playback.
|
| START DRAG |
<none>
|
| STOP |
<none>
Note that it is a good idea to stop sprites which don't need to be played back
in loops.
Also, if you have a one time playing movie (i.e. you use a STOP at
the very end) then you should put a START
in the very first frame so a rewind automatically restarts the movie
playback.
|
| STOP DRAG |
<none>
|
| STORE REGISTER |
[ REGISTER ':' ] expr
When outside of the FUNCTION
stores the top of the stack in register number 0, 1, 2 or 3.
Since version 7 of SWF, it is possible, when using a new type of
function, to use register numbers from 0 to 255.
Don't forget that this instruction doesn't actually pop the top
of the stack. It can be used to save something temporarilly which
will be reused in the expression a little later.
Prior version 7 of the SWF player, the registers where not saved
between function calls. In other words, calling a function can result
in destroying these registers (for C/C++ programmers: these were
globals.)
You can reload the content of a register using the
PUSH DATA
action.
|
| STRING |
<none>
|
| STRING EQUAL |
<none>
|
| STRING LENGTH |
<none>
|
| STRING LESS THAN |
<none>
|
| SUB MB STRING |
<none>
|
| SUB STRING |
<none>
|
| SUBTRACT |
<none>
|
| SWAP |
<none>
|
| THROW |
<none>
|
| TOGGLE QUALITY |
<none>
|
| TRACE |
<none>
|
| TRY |
This is a direct instruction: TRY.
|
| TYPE OF |
<none>
|
| URL |
[ URL | TARGET ':' ] expr, expr
[ METHOD ':' ] expr
Accepts a new URL (or an empty string) and
a target, or just a method (GET, POST or NOVAR[IABLE]).
The target can be set to "_level0"
in order to specify a new SWF file as the URL. The special target
"_level1" can also be used (for
what... I dunno - it seems to be in link with overlay capabilities).
If you want to go to a new page, like with a regular HTML
anchor, as the target, use one of "_top"
(remove all the frames) or "_self"
(replace the current frame only).
If you use an empty target, then a new window is created for the
destination URL to be displayed.
When a method is specified, then the new GET URL2
action is used. This means the target and URL are taken from
the stack. The method is saved within the tag and specify how
to deal with the SWF variables and how it should be forwarded
to the HTTP server.
|
| USHR |
Please see SHIFT RIGHT [UNSIGNED].
|
| WAIT FOR FRAME |
[ [ FRAME ':' ] expr ]
{ expr }
... play once frame loaded ...
This instruction waits for either the indicated
frame or the frame number as specified on the stack. If that frame
was already loaded, then the instructions specified within the
backets are executed.
Example:
ACTION "WAIT FOR FRAME" {
"motorbike";
ACTION "PLAY";
}
|
| WITH |
This is a direct instruction: WITH.
|
| XOR |
<none>
|
|
|
ACTION SCRIPT (one script) |
The ACTION SCRIPT object enables you to enter a Javascript like
program in an SSWF script. At the time this instruction is found,
the lexer switch to a new mode which enables the reading of the
action script written in Javascript code (for more information
about the Javascript language supported by SSWF, please look
at the Action Script Compiler
documentation.) Once the action script closing
brace is found, the SSWF lexer takes back over to parse what
follows in the file. Note that means you need the same number
of opening and closing braces in all your scripts which makes
a valid script anyway, so it should be easy.
The result of including an action script
is the same as adding actions one by one. The main difference
is that it is a lot easier to type complex expressions using
a language like Javascript. Also, it will be really easy to
manipulate objects. You can use an action script anywhere you
would otherwise be able to add actions. Note that you can't
mix actions and action scripts. Also, it won't be possible
for now to insert more than one action script where you can
put actions. This limitation is mostly a simplification, but
it certainly is what most people want anyway.
Note that at this time, it is not possible to request
the compiler to compile everything for a given version of
Flash. It will compile everything for version 7. If you
don't use some expression, you will be able to generate
code which will work with older versions but really there
is nothing garanteed. If you really need to use a specific
version, you could first use an action script, look at
the output (using swf_dump) and then replace the action
script with the output which you modify to get the version
you want.
|
7 |
BLOCK (composed and usually ordered) |
Please, see the LIST
object below.
|
n.a. |
BUTTON (semi-composed) |
Creates a button (end user interaction). Any button can be composed of multiple
STATE,
(when to display such and such edit text, shape, sprite or text) and
ACTION,
(what to do on a proper click). Actions include
LABEL,
FUNCTION and
WITH
instructions as well. It is possible to define a list of actions
to execute on a given set of events. This is done using an
ON EVENT
instruction.
If you want to create a menu, set the menu flag to true. The
menu flag is useful to allow users to drag the mouse between
different objects that pop up and out.
[ MENU ':' ] expr
{ expr }
|
1
Color Transform: 2
Menu: 3
Conditions: 3
Blend: 8
Filter: 8
|
CATCH (composed and ordered) This is an action. |
The CATCH instruction is an action which encapsulates other actions.
It is used to define an exception handler within a
TRY block.
Please, see the TRY reference for more information.
The CATCH needs to be named with either an alphanumeric name
or a register number between 0 and 255. The exception being thrown will
be saved in the named variable or the specified register. You can later
use the GET VARIABLE
action (in case you used a name) or the
PUSH DATA action
with 'register: <no>' to
read the error from the register.
{ expr }
The CATCH actions are executed when an exception occurs while
executing the actions defined in the TRY block.
|
7 |
| COLOR |
Accepts only one list of three or four values representing colors.
The expressions represent the luminance of the red, green,
blue and optional alpha. When the alpha is not defined, it is
supposed to be a solid color.
expr ',' expr ',' expr [',' expr]
|
1 |
| COLOR TRANSFORM |
Accepts one or two lists which represent how much to add to the color
and how much it will be scaled by. The values to add must be labeled
with ADD and the scaling factors by SCALE or MULT[IPLY].
The lists will be composed of three or four expressions to transform
the red, green, blue and alpha parameters of a color respectively. When
the alpha isn't specified, the default add is 0 and the default scale is
1.0. Only one of the field can be specified.
[ ADD ':' expr ',' expr ',' expr [ ',' expr ] ]
[ SCALE ':' expr ',' expr ',' expr [ ',' expr ] ]
|
1 |
DO ACTION (composed) |
This object expects a list of actions to execute unconditionally (though there can be
conditions within the actions). A list of actions is composed of the following
objects:
and an optional sprite identifier (V6.0+ only).
[ ID | INIT[IALIZE] | INITIALIZATION ':' ] expr
{ expr }
The following is an example on how to stop the movie from playing:
DO ACTION { ACTION "STOP"; };
|
1
Init: 6
ABC: 9
|
EDGES (ordered) |
Accepts one or more list of:
- Two expressions which define a line edge.
- Four expressions which define a 2nd degree spline curve edge by defining
a control point and an anchor.
- One labelled expression to specify a rotation angle. The order is important, only
the last rotate is taken in account for the following edges.
These lists of two or four expressions are
separated by semi-colons so as to defined multiple edges.
The last entry can be defined with the label CLOSE
in which case it will be given the start coordinates automatically. The
last two expressions following the CLOSE label are ignored. It is
vital to close a shape which needs to be filled.
{ [ CLOSE ':' ] expr ',' expr [',' expr ',' expr] }
{ ROTATE ':' expr }
A new position in a set of edges definitions are always relative
to the previous position. The first position is relative to the last MOVE of
the object including these edges (or the object origin when there wasn't a MOVE).
This also applies to the control points and anchors. That is, the position of an anchor
is relative to its control point (say p defines the previous point, c the control point and
a the anchor with standard 2 dimensional coordinates, the edges values to represent c
are: c - p, and for a it is: a - c). In order to
avoid these side effects, one can use the POINTS
object instead.
|
1 |
EDIT TEXT (semi-composed) |
In Flash movies it is possible to ask the user to enter information. These information
will be typed in text areas. These are defined with the EDIT TEXT.
An edit text is a very complex text that one can define in great details. The following
gives you a complete list of the options available with that object.
[ WORD[_]WRAP ':' expr ]
[ MULTILINE ':' expr ]
[ PASSWORD ':' expr ]
[ READ[_]ONLY ':' expr ]
[ NO[_]SELECT ':' expr ]
[ BORDER ':' expr ]
[ OUTLINE[S] ':' expr ]
[ HTML ':' expr ]
[ AUTO[_]SIZE ':' expr ]
[ MAX[[_]LENGTH] | LENGTH ':' expr ]
[ MARGIN | LAYOUT ':' expr, expr [ , expr, expr ] ]
[ ALIASING | THICKNESS_SHARPNESS ':' expr, expr ]
[ RENDERER ':' expr ]
[ GRID[[_]FIT] ':' expr ]
VAR[IABLE] ':' expr [ , expr ]
[ INIT | START ':' expr ]
[ ALIGN[MENT] ':' expr ]
[ USED[_]GLYPHS ':' expr ]
[ USED[_]STRINGS ':' expr ]
{ expr }
The AUTOSIZE BORDER HTML MULTILINE NOSELECT OUTLINES PASSWORD READONLY
and WORDWRAP are flags which can be set to
true or false.
All of these flags are mandatory. By default the word wrap and border flags are
true and all the others are false.
Please see the Alexis' SWF Reference
document for more info about the supported HTML tags.
The MAX_LENGTH parameter specifies the maximum length
in character of the text entry. This is mandatory. The default is to not constrain the
length.
The LAYOUT can be used to specify several parameters
useful to define the layout of the font versus the rectangle where the text is displayed.
The layout is composed of the left and right margin, and the mandatory indent and leading
sizes. The layout entry is mandatory.
The ALIASING parameter defines the thickness and sharpness to be used to
render the fonts. This may or may not be used by the system. Both values are floating
points expected to be positive. Use 0.0 to let the system use its internal default.
The RENDERER is a number (0 or 1) defining whether the normal Flash
animation rendering engine is used (0) or the new font rendering engine is used (1).
The definitions from system.sswf can be used (FONT_RENDERER_NORMAL and
FONT_RENDERER_FLASH.)
The GRID_FIT parameter defines whether the rendering happens as usual or
snaps to pixels to try to avoid most of the antialiasing. This accepts a value from
0 to 2 (in SSWF version 1.8.2). You can use the definitions from system.sswf instead
of typing a number (FONT_GRID_FIT_NO_GRID, FONT_GRID_FIT_PIXEL or FONT_GRID_SUBPIXEL)
The VARIABLE gives a name to this edit text object
(as a sprite). Changing the variable value changes the text being displayed and when the
user types in new text, it is also copied in this variable. This entry is required.
The INIT defines the text used to initialize the
edit text button. The default is none.
The ALIGNMENT can be one of LEFT, RIGHT, CENTER or JUSTIFY.
The USED_GLYPHS and USED_STRINGS will be used
to make sure that the referenced font has the given glyphs
defined. By default (if none of these two entries are defined),
all the glyphs are taken. The USED_GLYPHS can be used to
declare ranges with two characters separated by a dash
sign as in "A-Z0-9". The special string "*"
is taken as all the glyphs. The USED_STRINGS
is usually very good if you have many but a "fairly" small finite
list of strings to print within this EDIT TEXT
object. The dash sign (-) has no special meaning with the USED_STRINGS.
Because only one USED_STRINGS can be used, you need to
concatenate the different strings you want to use as in:
UsedGlyphs: "A-Z"; UsedStrings: "My Name" + "Charles 3" + "Albert 1" + "Henri 4";
This example ensures that all the uppercase letters are included
in the font. Then the lower case letters and digits necessary to write
the concatenated string "My NameCharles 3Albert 1Henri 4".
To complete the definition, it is necessary to define a
TEXT SETUP and a
RECTANGLE.
|
WARNING:
|
There seems to be a problem with the use of a system font when
that font doesn't exist on your system. At this time I do not
know if it only happens with this object or whether others
would also be affected too. Anyway, when it happens you get
nothing in the text area.
|
|
4
Settings: 8
Aliasing: 9
|
END (direct) |
This object can be used to mark the end of the tags. Note that the movie playback
can't go beyond an end tag whatsoever. You can mark the end of the tags in a
SEQUENCE or a SPRITE
object.
|
1 |
| ENVELOPE |
Defines a list of (a) position and a (b) left and (c) right volume
which can later be used in a
SOUND INFO
object. When no right volume is specified, the left is used for
both channels.
[ VOLUME ':' ] expr ',' expr [ ',' expr ]
|
2 |
| EXPORT |
It is possible to create a movie which is a place holder of
many definitions which is later included by other movies. This is
useful, for instance, to declare a large font so it is used by
different movies without having to include this large font within
each movie.
The draw back is that an IMPORT
instruction is necessary and this one uses a URL. This means a
dependency which is not automatically good to have on the Internet
for many reasons. Yet, this draw back isn't major in comparison to
the incredible time saving you can have using this feature.
The EXPORT instruction will include a list of pairs composed
of one reference to a definition and one string which is the
externally visible name for that definition.
ID | OBJ ':' expr ',' expr
Only definitions can be included in an export instruction:
|
5 |
FILL STYLE (composed and ordered) |
There are three different types of fill styles:
- A solid fill (SOLID) which accepts a COLOR.
- A gradient fill (RADIAL, LINEAR or FOCAL*) which accepts a GRADIENT and a MATRIX.
- A bitmap fill ([HARD-EDGE*] CLIPPED or [HARD-EDGE*] TILLED) which accepts an IMAGE and a MATRIX.
When the fill is used for a morph shape, then the different types of fill styles becomes:
- A solid fill (SOLID) which accepts two COLORs.
- A gradient fill (RADIAL, LINEAR or FOCAL*) which accepts a dual GRADIENT and two MATRICES.
- A bitmap fill ([HARD-EDGE*] CLIPPED or [HARD-EDGE*] TILLED) which accepts one IMAGE and two MATRICES.
* note that the HARD-EDGE option generates a Flash animation version 7.0
* note that the FOCAL option generates a Flash animation version 8.0
The TYPE of fill is specified with a string. This string can be one
of the following names:
"clipped" (bitmap)
"tilled" (bitmap)
"hard-edge clipped" (bitmap)
"hard-edge tilled" (bitmap)
"solid" (color)
"radial" (gradient)
"linear" (gradient)
"focal" (gradient)
"reset" (to remove the fill in a shape)
Other strings will make the fill style generate an error. When no
name is specified, the type of fill will be deduced automatically
however, in some cases it won't get it right. Also, by defining the
type of your fills you ensure you get that type. In other words, if
some parameters are not compatible with that type, the system
generates an error.
NOTE: naming the objects you are inserting in your fill styles
is usually equivalent to entering the fill type as a string as
described here. (1) gradients can be named "radial", "linear" or
"focal"; and (2) images can be named "clipping".
It is possible, for morphing shapes, to define solid, gradient
and bitmap morphing fills. In this case, the solid fill
will have two colors and both, the gradient and bitmap fills will
have two matrices. The order matters. Note that for bitmap fills
you don't have two images.
expr [',' expr]
ID | IMG ':' expr
[ TYPE ':' ] expr
The representation is one or two expressions
which can either be a reference to another object or a
direct definition of that object.
|
NOTE:
|
to clip a bitmap (though it really doesn't
seem necessary) one can use an empty image with the special name
clipping; thus one would declare the following:
IMAGE "clipping" { };
FILL STYLE "fill_clipping" {
MATRIX { SCALE: 20, 20; };
IMG: clipping;
};
and use the "fill_clipping" just before a
corresponding "fill_image".
|
|
1
Alpha: 3
Hard Edge: 7
Focal: 8
|
FINALLY (composed and ordered) This is an action. |
The FINALLY instruction is an action which encapsulates other actions.
It is used to terminate a TRY block.
Please, see the TRY reference for more information.
{ expr }
Whatever happens in the corresponding TRY and CATCH
blocks, the FINALLY actions are always executed.
|
7 |
FONT (semi-composed) |
Creates an SWF font. This is a list of glyphs or shapes that the following text
definitions can reuse. The scripting language will automatically remap the
characters in the text strings so you don't need to know how the glyphs are
mapped. At this time the order in which the glyphs are included defines the
mapping. This may change in the future and the order should not be taken
in account.
{ ID | CHAR ':' expr ',' expr [ ',' expr ] }
[ LANGUAGE ':' expr ]
[[ NAME ':' ] expr ]
[ DISPLAY NAME ':' expr ]
[ COPYRIGHT ':' expr ]
[ TYPE ':' expr [ ',' expr [ ',' expr [ ',' expr [ ',' expr ]]]]]
[[ LAYOUT ':' ] expr ',' expr ',' expr [ ',' expr ]]
[ ADVANCE ':' expr ]
[ SPACE ':' expr ]
[ { [ KERNING ':' ] expr ',' expr } ]
- A new character is defined with an ID
or CHAR introducer, a character name (a one character
string), a reference to a
GLYPH
or a SHAPE
and an optional character specific width. The following defines the upper case
character 'a':
CHAR: "A", my_font_upper_a, 100;
NOTE: don't forget that a reference is case
insensitive; thus you need to distinguish upper and lower case letters
better than in: my_char_a and my_char_A which
actually reference the same object. One way to do so is to define all
the lower cases in one list and all the upper case letters in another.
It is possible to not define any characters in the font. In
that case the NAME is mandatory and used to name the system
font to load.
IMPORTANT NOTE: Remember that a system font cannot be rotated. It can, however,
be scaled and translated. But it is likely to be rendered on a pixel boundary
and thus you won't be able to create very smooth movements with those.
A font can be NAMEd. The name will possibly be used by the
player to determine whether the font is available on the running system (i.e. a
system font or device font.) If so that font may be used instead of the internal
one. The font name is a string.
Since version 9, DISPLAY NAME can be used. This field is different
from the NAME field in that it is not used to load the font. It is only
the legal defining name.
Since version 9, a font can be given a license or COPYRIGHT.
So as to pick the proper system font you need to define
which type has to be used. The type is a list of 1 to 5 strings. The following
are currently accepted: ANSII, SHIFT-JIS,
UNICODE, BOLD, ITALIC and WIDE. Only
one of the ANSII, SHIFT-JIS and UNICODE
should be defined within one font.
Starting with version 6.x, you can specify a language for
the font (defining the language will force a v6.x movie). The
available languages (case insensitive) must be specified in
a string and can be any one of the following:
- Locale
- Latin
- Japanese
- Korean
- Simplified_Chinese
- Traditional_Chinese
For font definitions in V3.0+ one can define a complete
LAYOUT. This is done by defining 3 or 4 values which represent the ascent,
descent, leading height and advance. The advance can also be specified by
itself in which case it is taken in account in the TEXT
objects but doesn't generate a layout in the font.
The ADVANCE is used to specify the
width of all the characters, except those which have a specific width. It can
also be defined using the LAYOUT label. It is
possible to define the width of the SPACE character without
having to define it as a GLYPH.
This saves some space since (a) the final text strings won't include a
space and (b) there is no need for a glyph to draw nothing (this only
holds if no TextFields are used). The value specified with the
SPACE label is ignored if also a space (" ") glyph
is defined.
Finally, a set of KERNING entries
can be defined. These are defined with a two character string (such as "AV")
and an adjustment value. For instance, the character "A" may have a width of
100. However, when "AV" is written, a width of 90 could be more appropriate.
This is done by including a kerning as follow:
KERNING: "AV", -10;
|
1
Layout: 2
Unicode: 3
High resolution: 8
Alignment: 8
|
FOR (composed and usually ordered) |
The FOR will be used to generate a long list of entries. This could
be avoided once the complete set of action expressions are supported. At
this time, this instruction is particularly useful to declare a set of
PLACE OBJECT and
SHOW FRAME.
Note that these two objects will
be the most common within a FOR loop, yet this object doesn't test
what it includes and thus really anything can be defined within the loop.
The result is viewed as a list of the objects repeated
as expected.
FOR '(' IDENTIFIER '=' expr ';' expr ';' expr ')'
'{' object_definition '}'
At this time, the last expression must only be
an expression and should not be:
IDENTIFIER '=' <expr>
The following is an example which makes the movie pause
for 60 frames:
for(i = 0; i < 60; i + 1) {
show frame;
}
|
n.a. |
FRAME LABEL (direct) |
The FRAME LABEL will be used in order to compiled a named
frame within the final movie. This can be used as a web page
anchor in v6.x+.
It can also be useful in some scripts when you need to reference a
frame within a Push data.
The FRAME LABEL only accepts a name. If the name starts
with a hash sign (#) then it is taken as an anchor. The hash sign is
removed from the name before the movie is saved.
|
3
Script: 5
Anchor: 6
|
FUNCTION (composed and ordered) This is an action. |
The FUNCTION instruction is an action. Use it
to declare a function which you can later call with a
CALL FUNCTION
action. The name of the function (which is the name of this object) can
include a list of variable names separated by commas as in:
function "wait(seconds, useconds)" { ... }
Within the curvly brackets you can include any type of action
and since version 1.7.0, you can also include the definition of
another function. It is possible to create unnamed functions
which are pushed on the stack and can later be assigned
as methods to object.
Since version 1.7.0, you can (1) assign function parameters
to registers, (2) define the maximum number of registers you
will be using and (3) define special registers to be either
preloaded and suppressed.
The special registers are this, arguments,
super, _root, _parent and _global.
There is one special name which is _registers; it can
be followed by the total number of registers used by this
function. Note that in SWF Version 7, the players are
supposed to make the registers local to each function.
Specify the register number (or number of registers in
case of _registers) by following the variable name
with a colon (:) and a number in decimal as in:
function "foo(_registers:12, this, _root, param:3)" { ... }
Note that the player will automatically save the system
variables in registers (such as this and _root).
Thus, you don't need to specify a register number for those
(on the other hand, it can help you know what goes where.)
In this example, this will be saved in register 1,
_root in register 2 and param in register 3 as
specified. The _registers specification says that the
function should reserve 12 registers to run properly.
The assignment of register numbers to the system variables
is done in this order only (i.e. the order in which you
specify these special registers doesn't matter):
- this
- super
- _root
- _parent
- _global
Only the system variables which are specified are allocated
in registers. Thus, if you only specify this and
_global, only register 1 and 2 will be taken.
Important notes: (a) if you define one of your parameters with
a register number which is to be used by a system variable
then its content will be overwritten by the content of the
corresponding system variable; (b) if is possible to use
the special register 0 for user variables so SSWF automatically
allocates the proper registers for you; only problem: it
doesn't tell you what these registers are, but in a later
version, you will be able to specify the name of the parameter
in a PUSH DATA
with the type register and it will convert the name to
the corresponding register number as expected.
Finally, you can suppress the creation of system variables.
This can save some execution time when playing back the
animation since it won't have to allocate any resources
for these variables (really, I don't see the point, but
well... maybe I should try to write a player to understand
why this is necessary...). You can suppress any of the
this, arguments and super parameters.
To do so, preceed their name with a slash as in:
function "foo(_registers:12, /this, /arguments, _root, ignore:0)" { ... }
This function doesn't create this nor the
arguments (which is why I call our user parameter
ignore). Also, the parameter ignore will be given a
register number automatically.
expr
|
5
Auto-registers: 7
|
GLYPH (semi-composed and ordered) |
A GLYPH is a SHAPE
with some limitations. One will usually use a GLYPH instead of a
SHAPE in order to create the shapes for a font.
It is composed of at most one
RECTANGLE which defines
the character bounding box. When at least one character has a bounding box,
the FONT object will use a
DefineFont2 tag.
The turtle can be moved and the
FILL STYLE
can be changed before each set of
EDGES and
POINTS.
There can only be one fill style. You can switch between
having the FILL STYLE
turned on or off (use an empty fill style to turn off the filling). There
can't be any LINE STYLE.
Note that this option may be turned off in a later version since it doesn't seem that
it is necessary to have the fill style turned off and the style itself isn't
used anyway.
Note that the order matters since it will be
included in the specified order in the final shape object.
{ [ MOVE | OFFSET ':' ] expr ',' expr }
{ [ FILL0 ':' ] expr }
{ expr }
|
1
Over 255: 3
|
GRADIENT (semi-composed and ordered) |
Gradients are composed of a list of pairs. The pairs are composed
of one position (defined from 0.0 to 1.0 - it is also called ratio) and one
COLOR. When a gradient is
defined for a morph SHAPE,
their will be two pairs of position and color.
The order of the expressions matters for morph gradients. The first
two expressions define what to expect at position 0 and the last
two expressions what to expect at position 1.
It is also crutial to include a
MATRIX
(or two in a morphing gradient) in order to specify the rotation,
scaling and translation information.
The type of gradient can be specified with its name or a TYPE
in the FILL STYLE
including it. A gradient can either be named "linear", "radial" or "focal".
Other names will generate an error.
Since version 8, we can setup a focal point. This is done by
adding FOCAL and a position between -1.0 and +1.0, where 0.0 represents
the center, -1.0 represents the left side and +1.0 is the right side.
{ expr ',' expr [ ',' expr ',' expr ] }
object [ ',' object ]
FOCAL : float
You must have at least two pairs and at most eight for an animation
version 7 or less. If you run player version 8 or better, you can use
up to 15 pairs of position & color. The order to define the position
and color doesn't matter, however, in case of a morph it needs to be
the same for the two pairs.
|
1
Spread: 8
Interpolation: 8
Focal: 8
9 to 15 pairs
|
IF (composed) |
Conditional expressions can be added with the ?: operator. However
it is at times necessary to either have only one expression accepted or multiple
expressions in one go. For this purpose use the IF statement
instead.
In order to avoid conflicts in the grammar it was decided that
it is obligatory to have the curvely brackets around the blocks of expressions.
This anyway enhance the readability of scripts so it isn't so bad, is it?
IF '(' group_expr ')' '{' expr_list '}'
[ { ELSE IF '(' group_expr ')' '{' expr_list '}' } ]
[ ELSE '{' expr_list '}' ]
|
Notes:
|
(a) the '}''s before the ELSE's
are not followed by a colon;
|
(b) as a special case, an ELSE
can be followed by an IF without having to put that
IF within the curvely brackets;
|
|
n.a. |
| IMAGE |
It is necessary to specify the compression format and the name of a
file containing an image. At this time, targa and JPEG files are accepted
as input images. If you can't create 32 bits targa or use JPEG images (images which
include a mask) then you can specify two file names. The second file is
taken as a greyscale image and used as the alpha channel of the 1st image.
The format is specified as a label and can be
either JPEG or LOSSLESS[size]. It is suggested that
you use JPEG if you use a JPEG image as input.
When you create a JPEG image, it is possible to specify
the output quality of that JPEG with the QUALITY label and a value from
0 to 1. The default is whatever the JPEG group uses (usually 0.75). Note that
when you specify zero, the default value is used.
JPEG | LOSSLESS ':' expr [',' expr]
QUALITY ':' expr
The LOSSLESS label can also be LOSSLESS8 to force a colormap
image; LOSSLESS16 to force RGB555 and LOSSLESS32 to ensure
the full range of colors are saved as is. Using LOSSLESS without
a size lets the scripting tool decide which of the formats is best suited
for the given image.
|
1
Independent JPG: 2
Lossless: 2
Alpha: 3
|
| IMPORT |
When you have created one or more movies for inclusion in
several different other movies, you can import the data from
these movies with the IMPORT instruction.
This instruction accepts a list of names referencing the
objects within the exporting movie (only one movie can be imported
per IMPORT instruction.) Each name in the IMPORT list
needs to match one name in the referenced movie
EXPORT list of objects.
Like other definitions,
IMPORT definitions need to appear before being used.
After the name, it is possible to specify the type of object you are
importing. This way you can avoid problems by letting the system check
whether the object can be used wherever you are using it. In some cases,
the type is required (i.e. for fonts, sprite
for a DoAction, shape for a Font Glyph, image
for a fill style.) The type can be one of the following:
button
edit
font
image
shape
sound
sprite
text
Note that in some cases the type imported will be accepted
but that is not a correct type here.
When you have created the movie for inclusion, you can also
specify its FILENAME. The system may then use it to check the
imported object and ensure it will work as exported. This is
particularly useful for fonts. Note that the URL can't be
used since on the development system it's very unlikely that it
will work. Plus, it would be very slow to access the Network to
read a file you probably have right there on your hard disk.
The movie to import is specified within the given URL
label. It has to be a valid SWF movie with one EXPORT tag.
NOTE: an IMPORT, to be useful, will always be named since
in order to access the data within you will need a proper name.
URL ':' expr
FILENAME ':' expr
{ NAME ':' expr [ ',' expr ] }
|
5 |
| LABEL |
1. Object Names
It is at times necessary to reference an object in regard to its frame number.
This is done (a) by naming the object, or, (b) when
the name needs to be dynamic, by defining a label prior to the object.
The expression is expected to be a string. The following
is an example to show how a label is commonly used:
LABEL { strf("play_sprite%d", index) };
PLACE OBJECT { ... };
The PLACE OBJECT
receives the name "play_sprite1", "play_sprite2", etc. as the index is increment.
Variables can't be labelled. Some objects such as a sequence can't
be labelled.
It is an error to give two objects the same name.
2. Action Script Labels
It is at times necessary to jump from one place to another in
an action script. The different branch instructions will reuse
the label name.
It is an error to insert two labels with the same name.
Labels can be defined before or after the given branch
instruction(s).
In both cases a label is composed of one expression which
needs to be a string:
expr
|
n.a. |
LINE STYLE (semi-composed) |
Defines the styles of a line. This includes:
- Width — the thickness of the line; use two for morphing shapes
- Color — a solid color for the line; use two for morphing shapes
- Fill Style — an image or gradient fill for the line (instead of the color);
this is not supported with morphing shapes
- Caps — the start and end caps names; if you indicate only one, it is used for both caps;
The special value "none" means that it will look like a square and end exactly at the
given positions; so this is like "square" without the additions of caps (caps have a
length of
Width / 2).
- LINE_STYLE_CAP_ROUND (0)*
- LINE_STYLE_CAP_NONE (1)*
- LINE_STYLE_CAP_SQUARE (2)*
- Join — how to join different line segments, and the miter join limit factor (float)
- LINE_STYLE_JOIN_ROUND (0)*
- LINE_STYLE_JOIN_BEVEL (1)*
- LINE_STYLE_JOIN_MITER (2)*
- Scale — whether to scale the line horizontally and vertically (boolean);
if you indicate only one, both are set to the same value
- Pixel Hinting — whether points should be drawn on physical pixels (boolean);
keep to false (the default) if you intend to move your object slowly
- NoClose — whether the start and end point are standalone or forming a
closed shape (boolean)
* Defined in include/sswf/script/system.sswf
The minimum definition must be composed of one color and one width.
For a morphing shape, two widths and two colors are necessary.
Line fill using a fill style is not available for morphing shapes.
The other features are available with SWF version 8. It defines
better how lines have to be rendered.
At times it is necessary to remove the line style for the next part of a
shape. This is done with an empty line style: LINE STYLE "no_line" {};
WIDTH ':' expr [ ',' expr ]
CAPS ':' expr [ ',' expr ]
JOIN ':' expr [ ',' expr ]
SCALE ':' expr [ ',' expr ]
PIXEL[_]HINTING ':' exp
NO[_]CLOSE ':' exp
expr [ ',' expr ]
|
1
Over 255: 2
Alpha: 3
Morph: 3
Fill Style: 8
Caps: 8
Join: 8
Scale: 8
Pixel Hinting: 8
NoClose: 8
|
LIST | BLOCK (composed and usually ordered) |
This object is composed of any other object or variable. It
can be used as a repository of any type of object. The order
matters in case you want to access a list of items using the
array operator (expr '[' group_expr ']').
{ expr }
NOTE: a list is not an SWF object.
|
n.a. |
| MATRIX |
Composed of up to four entries each composed of one or two expressions.
The entries must be labelled as SCALE, ROTATE, TRANSLATE
or SKEW.
All the expressions must be values. The scale values are ratios. If only
one value is specified, then it is used to scale horizontally and vertically equaly.
The rotate value is an angle (in radians by default.) A positive rotation
angle will rotate the object counter clockwise from 3 o'clock. The
TRANSLATE represents coordinates in pixels where the object is moved
after it was scaled and rotated. The SKEW is to generate an
italic like effect of shapes. You should avoid using SKEW
and ROTATE at the same time. I'm not too sure right now how
to describe the type of value that SKEW uses. You should
use a value between -2.0 and +2.0. The default is 0.0. To get some
nice italic, a value of about -0.3 is usually enough.
SCALE ':' expr [ ',' expr ]
ROTATE ':' expr
TRANSLATE ':' expr ',' expr
SKEW ':' expr ',' expr
|
1 |
| METADATA |
The METADATA object generates a TagMetadata. This is composed of one
string with metadata information such as the title and description of your
animation.
You must choose between one of the following possibilities. If you
define a FILENAME and URL then the URL will
be ignored. The order below defines the priority (Use FILENAME
if defined, then XML and finally any other entry.)
- nothing
Used without any fields, the Metadata generates a default title,
description, type, etc.
- FILENAME
Specify the filename of an XML file which you want to load
as the animation description. This XML is expected to be well formed.
You can use xmllint to test that your XML is proper. When the filename
does not end with .xml and cannot be loaded as is, the library tries
again with .xml appended.
- XML
Defines a string composed of the XML information you want to save
in the animation. This strings needs to represent proper XML as
expected by Macromedia.
- direct content
- TITLE (dc:title)
- DESCRIPTION (dc:description)
- AUTHOR (dc:creator)
- PUBLISHER (dc:publisher)
- COPYRIGHT (dc:rights)
- URL (rdf:about attribute)
You can define one or more of these entries. In this case, these
strings are simple strings (no XML tag.) The SSWF library will
automatically generate the necessary XML tags to encompass this
information.
In this case, the <dc:type> is set to MovingImage
and the <dc:format> is set to application/x-shockwave-flash.
If you do not define a URL then the default
http://sswf.m2osw.com will be used.
Inserting several of these fields will result in one of
them being used and the others being ignored.
FILENAME ':' string
XML ':' string
TITLE ':' string
DESCRIPTION ':' string
AUTHOR ':' string
PUBLISHER ':' string
COPYRIGHT ':' string
URL ':' string
|
8 |
ON EVENT (semi-comp | | | |