asSWFbit_Library is a ActionScript based SWF Decompiler / Compiler for SWF files.
The library should help you to check, test and manipulate SWF files in any way you wanted.
The idea behind asSWFbit is to make it possible to provide a way fix small errors in a SWF file without needing a flash editor or the FLA files.
I hope you understand you should this only do for your own SWF files !
Please keep in Mind that English is not my native language, so I try my best to make a clear documentation in English.
When you find errors or something like that, please send me a short email what I can change or which part is mistakable.
Content
Manifestations about the asSWFbit Library
Errors, Improvements and Support
Installation of the asSWFbit Library
This is only a small Road map for the asSWFbit Library. Because I do this in my free time I will make no promise for any time lines or any other ETA for parts of the project.
Read Support (planned Q1/2011)
- SWF Header Information (Signature, Version, FileLength, Width, Height, FrameRate, FrameCount)
- FileAttributes (UseDirectBlit, UseGPU, HasMetadata, ActionScript3, UseNetwork)
- MetaData (CreatorTool, CreateDate, MetadataDate, ModifyDate, RAW)
- BackgroundColor
- ScriptLimits
- ...
- ActionScript Parser
Modify Support (planned Q3/2011)
- SWF Header
- FileAttributes
- MetaData
- ...
- ActionScript
Write Support (planned Q4/2011)
- SWF Header
- FileAttributes
- MetaData
- ...
- ActionScript
All items which are line-through are already implemented in the lasted version.
Other items are planned but not released in any version yet.
The License for asSWFbit is the BSD License, the License for the examples / documentation is the Creative Commons (by-sa) License.
Please also check http://code.google.com/p/asswfbit/ for more Information's.
asSWFbit is hosted on Google Code on this page you can download the lasted version of asSWFbit and submit errors and improvements.
First of all there is no direct Support for this project, please understand I do this in my free time and it takes a lot of time to write such a documentation.
So I have no time or the resources to answer direct support requests. Support requests to the contact email of the web page will be ignore and not answered.
When you find errors or have a idea of a improvement, please submit them over the Google Code web page http://code.google.com/p/asswfbit/.
asSWFbit Library 0.2 is available as package, copy the corresponding package folder "de" to the same place as the FLA file.

This examples shows how you can load and parse a flash file with the asSWFbit library.
The FLAs for these examples are also include in the example folder of the asSWFbit library.
Read SWF Header Information
The asSWFbit library has the option only to parse and read the SWF Header of a flash file.
When you only need these Information you should include the switch for a faster parsing of the SWF file.
The SWF Header include the following Information:
- Signature (FWS or CWS)
- Flash Version
- Uncompress file length
- Frame size (Dimension)
- Frame rate (Frames per seconds)
- Frame Count (Number of Frames)
/* Define and Load asSWFbit Library */
import de.markusbordihn.flash.as3.asSWFbit_Library;
var SWF_data = new asSWFbit_Library("Headers"); // Set Mode to Header only (faster)
/* Load SWF file into ByteArray */
var file:ByteArray = ...; // Could be any ByteArray which has load the SWF file
/* Check for valid SWF file and parse Information to text fields */
if (SWF_data.parse(file)) {
txt_signature.text = SWF_data.infos.Header.Signature;
txt_compress.text = SWF_data.infos.Header.Compress;
txt_version.text = SWF_data.infos.Header.Version;
txt_filelength.text = SWF_data.infos.Header.FileLength;
txt_width.text = SWF_data.infos.Header.Width;
txt_height.text = SWF_data.infos.Header.Height;
txt_framerate.text = SWF_data.infos.Header.FrameRate;
txt_framecount.text = SWF_data.infos.Header.FrameCount;
}
In this example you see it is very easy to check for a valid SWF file and read out the SWF Header Information of this SWF file.
The Library can be used on any ByteArray which has loaded a SWF file, so you can also use the URLLoader or the FileReference Object to load a SWF file into a ByteArray.
Read FileAttributes
Beside the Header Information there are some more Information which can be read out for more Information.
FileAttributes are available for flash files of version 8 and above.
So when the flash version is 7 and below you will not see any FileAttributes.
The FileAttributes include the following information:
- UseDirectBlit (Hardware Acceleration)
- UseGPU (Graphic Card Acceleration)
- HasMetadata (Metadata)
- ActionScript3 (Define if the file use ActionScript 3)
- UseNetwork (Local Sandbox Setting)
/* Define and Load asSWFbit Library */
import de.markusbordihn.flash.as3.asSWFbit_Library;
var SWF_data = new asSWFbit_Library();
/* Load SWF file into ByteArray */
var file:ByteArray = ...; // Could be any ByteArray which has load the SWF file
/* Check for valid SWF file and parse Information to text fields */
if (SWF_data.parse(file)) {
...
if (SWF_data.infos.Header.Version >= 8) { // Exists only in flash files version 8 or higher
txt_usedirectblit.text = SWF_data.infos.FileAttributes.UseDirectBlit;
txt_usegpu.text = SWF_data.infos.FileAttributes.UseGPU;
txt_hasmetadata.text = SWF_data.infos.FileAttributes.HasMetadata;
txt_actionscript3.text = SWF_data.infos.FileAttributes.ActionScript3;
txt_usenetwork.text = SWF_data.infos.FileAttributes.UseNetwork;
}
}
Here we use first the SWF Header Information to check if the flash file is version 8 or higher.
When yes we can read out and display the FileAttributes Information.
Read Metadata
The Metadata are sometime very helpfully. They can include a lot of Information. You can also define to include your own Information.
The asSWFbit Library parse some of the values automatically, but you have still access to the full raw xml information.
The most common / default information are the following:
- CreatorTool
- ModifyDate
- CreateDate
- Author / Creator
- Description
/* Define and Load asSWFbit Library */
import de.markusbordihn.flash.as3.asSWFbit_Library;
var SWF_data = new asSWFbit_Library();
/* Load SWF file into ByteArray */
var file:ByteArray = ...; // Could be any ByteArray which has load the SWF file
/* Check for valid SWF file and parse Information to text fields */
if (SWF_data.parse(file)) {
...
if (SWF_data.infos.Header.Version >= 8) { // Exists only in flash files version 8 or higher
...
if (SWF_data.infos.FileAttributes.HasMetadata) { // FileAttributes tell us if there are Metadata
txt_creatortool.text = SWF_data.infos.Metadata.Description.xmp.CreatorTool;
txt_metadatadate.text = SWF_data.infos.Metadata.Description.xmp.MetadataDate;
txt_modifydate.text = SWF_data.infos.Metadata.Description.xmp.ModifyDate;
txt_createdate.text = SWF_data.infos.Metadata.Description.xmp.CreateDate;
txt_creator.text = SWF_data.infos.Metadata.Description.dc.creator;
txt_description.text = SWF_data.infos.Metadata.Description.dc.description;
txt_title.text = SWF_data.infos.Metadata.Description.dc.title;
txt_metadata.text = SWF_data.infos.Metadata.raw;
}
}
}
Here you see that most of the xmp entry's and dc entry's are already parsed to a variable for a easy access.
The raw xml data are stored in "infos.Metedata.raw". Please keep in mind that this xml is working with namespace, so you need to defined namespace variables to access the different information in the raw data.
Read BackgroundColor and ScriptLimits
The BackgroundColor and ScriptLimits are sometime very intresting information. Please keep in mind that the SWF will only store ScriptLimits when there are different from the default Settings.
/* Define and Load asSWFbit Library */
import de.markusbordihn.flash.as3.asSWFbit_Library;
var SWF_data = new asSWFbit_Library();
/* Load SWF file into ByteArray */
var file:ByteArray = ...; // Could be any ByteArray which has load the SWF file
/* Check for valid SWF file and parse Information to text fields */
if (SWF_data.parse(file)) {
...
if (SWF_data.infos.BackgroundColor) {
txt_backgroundcolor.text = SWF_data.infos.BackgroundColor;
}
if (SWF_data.infos.ScriptLimits) {
txt_maxrecursiondepth.text = SWF_data.infos.ScriptLimits.MaxRecursionDepth;
txt_scripttimeoutseconds.text = SWF_data.infos.ScriptLimits.ScriptTimeoutSeconds;
}
}
The format of the BackgroundColor is in the RGB (Red Green Blue) Format: RRGGBB.
Read all TAGs
You can also read all TAGs of a SWF file to search for a special TAG or to get a general Overview over the SWF itself.
It is possible to access the raw content of each TAG, the parsed content is only available when the asSWFbit Library support the TAG.
/* Define and Load asSWFbit Library */
import de.markusbordihn.flash.as3.asSWFbit_Library;
var SWF_data = new asSWFbit_Library();
/* Load SWF file into ByteArray */
var file:ByteArray = ...; // Could be any ByteArray which has load the SWF file
/* Check for valid SWF file and parse Information to text fields */
if (SWF_data.parse(file)) {
...
if (SWF_data.infos.TAGs) {
txt_tags.text = "Found " + SWF_data.infos.TAGs.NumberOfTAGs + " TAGs...\n=========================================\n";
for (var id:uint = 0; id < SWF_data.infos.TAGs.NumberOfTAGs; id++) {
if (SWF_data.infos.TAGs["ID" + id]) {
txt_tags.appendText(id+'\t:\t' + SWF_data.infos.TAGs["ID" + id].name + " (size: " + SWF_data.infos.TAGs["ID" + id].size + ")\n");
}
}
}
}
All TAGs from a SWF file are stored at infos.TAGs, so when this is existing then you can be sure that the SWF file has some TAGs inside.
Each TAG has a unique ID over which you can access additional information. For more Information about the structure of this, please look at the "TAGs" section.
This is a detail overview, which show all functions, events and constructors of the asSWFbit Library.
Below this there are more details information for each function, event and constructor.
Overview over constructors
| Syntax | Description | ||
|---|---|---|---|
asSWFbit_Library(Mode:String) | Create a asSWFbit_Library-Object. With the mode you can disable or enable additional features. "Headers" will only parse the Header Information and no additional TAGs or Information. |
||
Overview over functions
| Syntax | Description | ||
|---|---|---|---|
parse(_DATA_:ByteArray) : Boolean | Try to load and parse the SWF file inside the ByteArray. Return true when there is a valid SWF file inside this ByteArray. | ||
Overview over "infos" objects
The "infos" object is only available after parsing over the "parse" function and keep all Information about the SWF file.
| Path | Description | ||
|---|---|---|---|
infos.Header | Include all SWF Header information like Version, Filesize, Compress, Dimension | ||
infos.FileAttributes | Include all the FileAttributes information like ActionScript3, Metadata. | ||
infos.Metadata | Include all Metadata like Creator, CreatorTool, CreationDate. | ||
infos.BackgroundColor | Include only the BackgroundColor in the RGB Format. | ||
infos.ScriptLimits | Include all ScriptLimits information like MaxRecursionDepth and ScriptTimeoutSeconds. | ||
infos.TAGs | Include all TAGs from the SWF file in a special format. | ||
Overview over "infos.TAGs" objects
The "infos.TAGs" object include all TAGs from the SWF file in this special format.
| Path | Description | ||
|---|---|---|---|
infos.TAGs.index | Small search Index for the most commend SWF Information. | ||
infos.TAGs.NumberOfTAGs | Include the Number of TAGs which was found in the SWF file. | ||
infos.TAGs["ID..."] | For each TAG there is a unique Object with a ID. | ||
infos.TAGs["ID..."].type | Include the Type ID of the TAG. | ||
infos.TAGs["ID..."].name | Include the name of the Type of the TAG. | ||
infos.TAGs["ID..."].start | Start Position of the TAG inside the DataArray | ||
infos.TAGs["ID..."].end | End Position of the TAG inside the DataArray | ||
infos.TAGs["ID..."].size | Size of the raw data, exclude type header | ||
infos.TAGs["ID..."].pos | Overall Position of the TAG in the Object | ||
infos.TAGs["ID..."].raw | Raw data of the TAG, exclude type header | ||
infos.TAGs["ID..."].content | Parsed raw data, depend on the type which information are here. | ||
