-
Notifications
You must be signed in to change notification settings - Fork 127
Home
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.
Open the Flash IDE. Create a new AS3 project. Add as3swf.swc. Put this 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: ffff0000
LineStyles:
[1] [SWFLineStyle2] Width: 20, StartCaps: round, EndCaps: round, Joint: round, Color: ff000000
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]
FC64 (SWF9)
DENG (SWF6)
YouTube (SWF8)
Vimeo (SWF9)
All Your Base (SWF4)
Tag ID | Read | Write | Tag Name |
0 | x | x | End |
1 | x | x | ShowFrame |
2 | x | DefineShape | |
4 | x | PlaceObject | |
5 | x | x | RemoveObject |
6 | x | x | DefineBits |
7 | x | DefineButton | |
8 | x | x | JPEGTables |
9 | x | x | SetBackgroundColor |
10 | x | DefineFont | |
11 | x | DefineText | |
12 | x | x | DoAction |
13 | x | DefineFontInfo | |
14 | x | x | DefineSound |
15 | x | StartSound | |
17 | x | DefineButtonSound | |
18 | x | SoundStreamHead | |
19 | x | x | SoundStreamBlock |
20 | x | x | DefineBitsLossless |
21 | x | x | DefineBitsJPEG2 |
22 | x | DefineShape2 | |
23 | x | DefineButtonCxform | |
24 | x | x | Protect |
26 | x | x | PlaceObject2 |
28 | x | x | RemoveObject2 |
32 | x | DefineShape3 | |
33 | x | DefineText2 | |
34 | x | DefineButton2 | |
35 | x | x | DefineBitsJPEG3 |
36 | x | x | DefineBitsLossless2 |
37 | x | DefineEditText | |
39 | x | x | DefineSprite |
41 | x | ProductInfo | |
43 | x | x | FrameLabel |
45 | x | SoundStreamHead2 | |
46 | x | DefineMorphShape | |
48 | x | DefineFont2 | |
56 | x | x | ExportAssets |
57 | x | x | ImportAssets |
58 | x | x | EnableDebugger |
59 | x | x | DoInitAction |
60 | x | DefineVideoStream | |
61 | x | x | VideoFrame |
62 | x | DefineFontInfo2 | |
63 | x | DebugID | |
64 | x | x | EnableDebugger2 |
65 | x | x | ScriptLimits |
66 | x | x | SetTabIndex |
69 | x | x | FileAttributes |
70 | x | PlaceObject3 | |
71 | x | x | ImportAssets2 |
73 | x | DefineFontAlignZones | |
74 | x | x | CSMTextSettings |
75 | x | DefineFont3 | |
76 | x | x | SymbolClass |
77 | x | x | Metadata |
78 | x | DefineScalingGrid | |
82 | x | x | DoABC |
83 | x | DefineShape4 | |
84 | x | DefineMorphShape2 | |
86 | x | x | DefineSceneAndFrameLabelData |
87 | x | x | DefineBinaryData |
88 | x | DefineFontName | |
89 | x | StartSound2 | |
90 | x | x | DefineBitsJPEG4 |
91 | x | DefineFont4 |
Tests – IN PROGRESS
ASDocs
Complete support for publishing SWF from DOM – IN PROGRESS
Provide convenience methods to import/export various types of assets (bitmaps, sounds, fonts, ..)
Add parseXML and publishXML methods to import from and export to a swfmill like XML
Decompile Actions (to AS1 and AS2) and ABC (to AS3)
Compile AS1 and AS2 (to Actions) and AS3 (to ABC)