Skip to content
This repository

as3swf is a low level Actionscript 3 library to parse, create, modify and publish SWF files.

Alpha version, under active development. Please do not use in production just yet.

as3swf is brought to you by Claus Wahlers and côdeazur

Watch it, Clone it, Fork it – as3swf is licensed under the MIT license. Contributions are very welcome.


Usage

Open the Flash IDE. Create a new AS3 project. Add as3swf.swc. Put this code on frame one:

import com.codeazur.as3swf.SWF;
var swf:SWF = new SWF(root.loaderInfo.bytes);
trace(swf);

Result: Traces an object dump of itself

[SWF] Version: 10, FileLength: 147508, FileLengthCompressed: 147508, FrameSize: (550,400), FrameRate: 24, FrameCount: 1, Tags: 7
  Tags:
    [69:FileAttributes] AS3: true, HasMetadata: false, UseDirectBlit: false, UseGPU: false, UseNetwork: false
    [09:SetBackgroundColor] Color: #FFFFFF
    [86:DefineSceneAndFrameLabelData] 
      Scenes:
        [0] Offset: 0, Name: Scene 1
    [82:DoABC] Lazy: true, Length: 147408
    [76:SymbolClass] 
      Symbols:
        [0] TagID: 0, Name: Untitled_fla.MainTimeline
    [01:ShowFrame] 
    [00:End] 

Now draw a rectangle on stage, with solid stroke and fill. Run the SWF again.

Result: The object dump shows an additional DefineShape tag (which defines the geometry and style of the rectangular shape we have drawn on stage) along with a PlaceObject tag (which places the previously defined shape on the display list at a certain depth):

[SWF] Version: 10, FileLength: 147573, FileLengthCompressed: 147573, FrameSize: (550,400), FrameRate: 24, FrameCount: 1, Tags: 9
  Tags:
    [69:FileAttributes] AS3: true, HasMetadata: false, UseDirectBlit: false, UseGPU: false, UseNetwork: false
    [09:SetBackgroundColor] Color: #FFFFFF
    [86:DefineSceneAndFrameLabelData] 
      Scenes:
        [0] Offset: 0, Name: Scene 1
    [83:DefineShape4] ID: 1, ShapeBounds: (590,2810,430,1970), EdgeBounds: (600,2800,440,1960)
      FillStyles:
        [1] [SWFFillStyle] Type: 0 (solid), Color: #FF0000/FF
      LineStyles:
        [1] [SWFLineStyle2] Width: 20, StartCaps: round, EndCaps: round, Joint: round, Color: #000000/FF
      ShapeRecords:
        [SWFShapeRecordStyleChange] MoveTo: 2800,1960, FillStyle1: 1, LineStyle: 1
        [SWFShapeRecordStraightEdge] Horizontal: -2200
        [SWFShapeRecordStraightEdge] Vertical: -1520
        [SWFShapeRecordStraightEdge] Horizontal: 2200
        [SWFShapeRecordStraightEdge] Vertical: 1520
        [SWFShapeRecordEnd]
    [26:PlaceObject2] Depth: 1, CharacterID: 1, Matrix: (1,1,0,0,0,0)
    [82:DoABC] Lazy: true, Length: 147408
    [76:SymbolClass] 
      Symbols:
        [0] TagID: 0, Name: Untitled_fla.MainTimeline
    [01:ShowFrame] 
    [00:End]

Trace dumps of selected SWFs

FC64 (SWF9)
DENG (SWF6)
YouTube (SWF8)
Vimeo (SWF9)
All Your Base (SWF4)


TODOs, Roadmap

Tests
ASDocs
Complete support for publishing SWF from DOMDONE
Provide convenience methods to import/export various types of assets (bitmaps, sounds, fonts, ..)

Something went wrong with that request. Please try again.