Is it text? Yes, and it is never compiled. Every script in an XFL
document is kept as the source text exactly as it was typed in the Actions panel, with
its comments, tabs and line breaks. It is UTF-8, like the rest of the XML, inside a
<![CDATA[ … ]]> section of a <script> element, so
it can be read with any text editor once the archive is unzipped. Compiling to AVM1
actions or AVM2 bytecode happens only when the document is published as a
SWF. The only compiled code an XFL
document holds is inside compiled clips and components, which are SWF files in
bin/.
Scripts are found in two places in the XML, frames and symbol instances. Classes are
never in the document: it only names them, and their code is in
.as files beside it.
| What | Where | Form |
|---|---|---|
| Frame scripts | <DOMFrame> → <Actionscript> → <script>, in DOMDocument.xml for scenes and in LIBRARY/*.xml for symbols | Text (UTF-8) |
| Instance handlers (ActionScript 1.0 and 2.0) | <DOMSymbolInstance> → <Actionscript> → <script> | Text (UTF-8) |
| Linkage classes | linkageClassName on library items; the class in an .as file on the class path | A name only |
| Document class (ActionScript 3.0) | <DocumentClass> in PublishSettings.xml; the class in an .as file | A name only |
| Included files | An #include or include directive in a script; the file outside the document | A file name only |
Frame scripts
A script on a keyframe is the <Actionscript> child of its
<DOMFrame>, holding one <script> whose content is
the text. A scene’s frames are in DOMDocument.xml; a movie clip’s or
button’s are in its own file in LIBRARY/.
<DOMLayer name="[actionscript]" color="#FFFF4F" current="true" isSelected="true" autoNamed="false">
<frames>
<DOMFrame index="0" keyMode="9728">
<Actionscript>
<script><![CDATA[//----------------------------------------------------------
// Very simple preloader
//----------------------------------------------------------
if (this.stage.loaderInfo.bytesLoaded / this.stage.loaderInfo.bytesTotal >=1)
gotoAndStop("connect");]]></script>
</Actionscript>
<elements/>
</DOMFrame>
[actionscript], in a Flash CS5.5 documentWhere a script runs follows from where it sits:
- the timeline is the scene (the
nameof the<DOMTimeline>) or the symbol whose file holds it; - the layer is the
nameof the enclosing<DOMLayer>; - the frame is the keyframe’s
index+ 1. The script runs when the playhead enters that frame, and the keyframe lasts fordurationframes.
The language is the one <ActionScriptVersion> in
PublishSettings.xml gives: 3 in the example, so the script is
ActionScript 3.0, run as a method of the timeline’s
class.
Handlers on instances
In ActionScript 1.0 and 2.0 documents a script can also sit on a button or movie clip
instance on the stage: an on (release) { … } or onClipEvent
(enterFrame) { … } handler. It is stored the same way, as an
<Actionscript> child holding a <script>, but
inside the <DOMSymbolInstance> in the frame’s
<elements>. Its frame and layer are those of the frame that holds
the instance, and the instance’s libraryItemName and name say
what it belongs to.
This is how the explorer reads instance handlers; no ActionScript 2.0 XFL document was available to check it against. ActionScript 3.0 does not allow scripts on instances, so ActionScript 3.0 documents have only frame scripts.
Classes
ActionScript 2.0 and 3.0 classes are not stored in the document. Each lives in its own
.as file, named after the class, in folders named after its package, on
the class path. The document only names classes, in two places:
- Linkage classes. A library symbol exported for ActionScript has
linkageExportForAS="true", its class inlinkageClassNameand, for ActionScript 3.0, the class that extends inlinkageBaseClass(such asflash.display.Sprite). When no.asfile of that name exists, Flash generates the class when publishing. See The library. - The document class, below.
A compiled clip’s class (linkageClassName and
actionscriptClass on its <DOMCompiledClipItem>) is the
exception: it is already compiled, inside the clip’s SWF in bin/.
The class path for ActionScript 3.0 is <AS3PackagePaths> in
PublishSettings.xml, together with the paths set in Flash’s own
preferences; . means the folder of the .fla. ActionScript 2.0
uses its own classpath, described with the
ActionScript 2.0 packages.
The document class
An ActionScript 3.0 document can name a class for its main timeline: the document
class, in <DocumentClass> under
<PublishFlashProperties> in PublishSettings.xml. For
example classes.SimpleMMOWorld is the class
SimpleMMOWorld in package classes, found as
classes/SimpleMMOWorld.as under a folder of the class path, here the
document’s own folder. The class extends MovieClip or
Sprite, and its constructor runs when the SWF starts. See
The document class in the
ActionScript 3.0 reference.
Because the class is outside the .fla, a document without its
.as files cannot be published as it was; the frame scripts alone are only
part of the program.
Included files
A script can pull in another file’s text when the document is published. In
ActionScript 1.0 and 2.0 the directive is #include "Script.as"; in
ActionScript 3.0 it is include "Script.as", without the
#. The document holds only the directive, as part of the script’s text; the
file is looked for relative to the .fla. The explorer lists the files
named by #include in the scripts, with the document’s details.
What the explorer shows
For an XFL document the explorer gathers every script in
DOMDocument.xml and the symbol files into one text. Each script is headed
with where it is, for example:
// ---- scene "Scene 1", layer "[actionscript]", frame 9 · DOMDocument.xml
A Scripts table lists them with the timeline, layer, frame, kind (frame script or
instance), the member that holds it, the number of lines and the first line; clicking
a row opens that member. A Classes table lists the document class and every linkage
class, with the symbol it belongs to, its base class and the .as file it
would be in, and a Timelines table counts the layers, frames and scripts of each scene
and symbol.
Related pages
- ActionScript – the language and its
.assource files - ActionScript 2.0 – classes in
.asfiles, compiled for AVM1 - ActionScript 3.0 – packages and classes for the AVM2
- ActionScript in SWF – the compiled form: AVM1 actions and AVM2 ABC bytecode