as3swf is a low level Actionscript 3 library to parse, create, modify and publish SWF files.
as3swf is released under the MIT license.
For more info, please visit the as3swf Wiki
Low level Actionscript 3 library to parse, create, modify and publish SWF files.
License: MIT License
as3swf is a low level Actionscript 3 library to parse, create, modify and publish SWF files.
as3swf is released under the MIT license.
For more info, please visit the as3swf Wiki
Unknown fill style type: 0x63, Tag: DefineMorphShape2, Index: 4
http://dl.dropbox.com/u/447604/error.swf
http://dl.dropbox.com/u/447604/error.fla
If a shape is made using texture for Stoke color, then SWF() throws error "Unknown fill style type: 0x5f". I provide you with the link to test fla file. You can repoduce error just by compiling it from IDE.
Thanks much for you efforts!
Just to thank you very much and inform you that I use your lib in my project, that's an awesome lib, thanks again !
Hi All,
I am trying to determine how to make changes to scripts on the timeline. For example my original SWF has the following:
var filetype = "parent";
Any derivative from this SWF I would like to change the variable filetype to "child".
After looking at the "loaderInfo.bytes" in its raw format I am not able to find the code that is added to the timeline. I see that external classes can be referenced but that would mean that I would have to update the external class as well at run time.
Thanks...
Is it possible to embed TTF font while creating new SWF using this lib ? If so, can you please give an example.
Thanks :)
This is not a bug, but more of a question.
I've loaded a basic SWF and traced the bytes from a TagDoABC. I could recognize a lot of the elements, knowing the original code, but I was wondering if there is a way to convert this to a more readable format.
If so, how ?
Thank you for your time,
George
Is there a way to include actionScript or to include internal swf?
Can i use this lib if the target SWF to edit are built with AS2?
I am loading external SWFs and they are playing Video on the stage. I want to access the NetStream object itself in order to find out the URL of the playing mp4.
Can I do it with help of your lib?
Is there some kind methods for this?
Thanks in advance.
It incorrectly claims that 32 BPP bitmaps are 24 BPP encoded.
Hi Claus, this lib is really powerfull stuff ! thanks for putting this online !
but - I can`t seem to get some swf file converted, they all have defineShape3 and defineFont3 in them. These were swf file created with illustrator.
If I flatten them in flash, they will export to svg just fine.
Is there any quick workaround I could do to have these shape/group of shape exported ?
I found that if I use this statement, - if ( !defineShape || !defineShape.shapes ) continue;
the shape will be exported but no matrix will be accounted for.
text does not seem to render at all.
here are two example files.
file with defineShape3 - http://atomikspace.com/transfer/A.swf
file flatten to use defineShape4 - http://atomikspace.com/transfer/b.swf
any help will be Insanely appreciated !
The "4 - PublishModifiedLogo.fla" and "5 - ShapeExportLogo_AS3.fla" examples are not compiling because it looks like the getTagByCharacterId( characterId:uint ) method of the SWFTimelineContainer.as class changed to getDefinition( characterId:uint ).
fontHeight should be read when hasFont or hasFontClass is true.
Currently it's only being read when hasFont is true.
When creating this package you should've committed to supporting this open source package till death do you part. If you don't continue to develop this package you will ruin the sanctity of free and open source development forever. You not developing this package further is encroaching on my right to free quality software! 😺
I need to get the compiledate from the bytecode, but SWFs generated by ASC2 produce bytes in a different order than the ASC1 does.
I've been playing around with as3swf and am very impressed with what it can do. I've tested it on a number of SWFs and most of them work properly, but I've run into an error.
Here's the stacktrace:
ReferenceError: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value.
at com.codeazur.as3swf::SWF/getTagByCharacterId()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWF.as:48]
at com.codeazur.as3swf::SWFTimeline/getTagByCharacterId()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWFTimeline.as:86]
at com.codeazur.as3swf::SWFTimeline/buildLayers()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWFTimeline.as:324]
at com.codeazur.as3swf::SWFTimeline/parseFinalize()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWFTimeline.as:175]
at com.codeazur.as3swf::SWFTimeline/parse()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWFTimeline.as:92]
at com.codeazur.as3swf::SWF/parse()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWF.as:68]
at com.codeazur.as3swf::SWF/loadBytes()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWF.as:55]
at com.codeazur.as3swf::SWF()[/Users/claus/Projects/as3swf/src/com/codeazur/as3swf/SWF.as:34]
at com.SWFScraper::SWFScraper/processByteArrays()[C:\Users_\SWFDetailsExtractor\src\com\SWFScraper\SWFScraper.as:105]
at com.SWFScraper::SWFScraper/loadedSWF()[C:\Users_\SWFDetailsExtractor\src\com\SWFScraper\SWFScraper.as:88]
and the console output in FlashDevelop:
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 299
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 325
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 350
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 368
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 384
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 402
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 502
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 641
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 654
WARNING: parse error: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value., Tag: DefineSprite, Index: 693
[Fault] exception, information=ReferenceError: Error #1069: Property undefined not found on AS3.vec.Vector.com.codeazur.as3swf.tags::ITag and there is no default value.
Is there any known reason it would try pull a value from the timeline dictionary that doesn't exist?
Thanks
The g tag should have a transform attribute to specify the position of the path. Currently the path always starts at 0, 0.
I noticed all TagDefineShape in the SWF, their shapeBounds have x =0 and y=0.
SWFData.as, Line 812 1137: Incorrect number of arguments. Expected no more than 0.
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.events.Event;
import com.codeazur.as3swf.SWF;
import flash.net.URLRequest;
import flash.filesystem.File;
import flash.utils.ByteArray;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;
import com.codeazur.as3swf.tags.TagFileAttributes;
import com.codeazur.as3swf.tags.TagEnd;
import com.codeazur.as3swf.tags.TagDefineSprite;
import com.codeazur.as3swf.tags.TagShowFrame;
import com.codeazur.as3swf.data.SWFMatrix;
import com.codeazur.as3swf.tags.TagPlaceObject;
var urlLoader:URLLoader = new URLLoader();
urlLoader.load(new URLRequest(File.desktopDirectory.resolvePath("a.swf").nativePath));
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE,onCmp);
function onCmp(e:Event):void{
var swf:SWF = new SWF(e.currentTarget.data);
var tagSpr:TagDefineSprite;
for(var i:int =0;i<swf.tags.length;i++){
if(swf.tags[i] is TagDefineSprite){
tagSpr = swf.tags[i] as TagDefineSprite;
}
}
var newswf:SWF = new SWF();
newswf.tags.push(new TagFileAttributes);
newswf.tags.push(tagSpr)
var tagPlaceObj:TagPlaceObject = new TagPlaceObject();
tagPlaceObj.hasCharacter = true;
tagPlaceObj.characterId = 2;
tagPlaceObj.depth = 99;
tagPlaceObj.hasMatrix = true;
tagPlaceObj.matrix = new SWFMatrix();
newswf.tags.push(tagPlaceObj);
newswf.tags.push(new TagShowFrame);
newswf.tags.push(new TagEnd);
var ba:ByteArray = new ByteArray();
newswf.publish(ba);
var fileStream:FileStream = new FileStream();
fileStream.open(File.desktopDirectory.resolvePath("b.swf"),FileMode.WRITE);
fileStream.writeBytes(ba);
fileStream.close();
fileStream = null;
}
问题:newswf.tags.push(tagSpr) 这个句子无法创建成功,can not create a sprite to a swf file successfully
劳资找遍百度、谷歌、雅虎都没找到成功new DefineSprite()的方法,尼玛!万分无奈之下求助于楼主。希望楼主大神指教下,楼主好人,感谢楼主!
How to create Shape from Bitmap?
Hi again,
Was wondering what is the best way to export embeds, currently this doesn't work in easyWorker:
PBPickingCollider_RayTriangleKernelClass is a pixelbender embed that is part of the away3d library:
public class PBPickingCollider extends PickingColliderBase implements IPickingCollider
{
[Embed("/../pb/RayTriangleKernel.pbj", mimeType="application/octet-stream")]
private var RayTriangleKernelClass:Class;
After publishing and loading the swf that use it:
Worker 2: [Fault] exception, information=ReferenceError: Error #1065: Variable PBPickingCollider_RayTriangleKernelClass is not defined.
All what I do is taken the ABC Code, the TagSymbolClass and I even tried to publish the TagExportAssets from the orignal one but with no success.
Thanks,
-Fred
Wasn't sure where best to bring this up, but I've a question about taking run-time display variables when using as3swf.
It seems like this could/can take "DisplayObject"s created at runtime (e.g. "MovieClip"s), and store them in the swf being created. Basically emulating the "DefineSprite" tag, but, also recursively scanning through adding children, retaining matrix information (position, scaling etc) for all children of the added object.
Something akin to;
var asset:DisplayObject; // thing that's full of visuals altered at run-time
var assetTag:TagDefineSprite = new TagDefineSprite();
assetTag.ParseAsset( asset );
var swf:SWF = new SWF();
swf.tags.push( new TagFileAttributes() );
swf.tags.push( assetTag );
...
Is there a way of doing this?
Perhaps some way of serialising "DisplayObject"s into "ByteArray"s that "SWF" could take as a valid constructor parameter, like how stage.loaderInfo.bytes can be used. I know that ByteArray.writeObject( obj ) doesn't play well with MovieClips, but is there a nice away around this?
It seems like a pretty useful thing if it is possible, so I'm surprised no else has asked... (sorry if this is because the answer is obvious!)
It's a waste of time for users of the parser to sit and manually write pixel data decoders when the parser should be doing it for them.
This error is happening in 'SwfTimelineContainer.as' when I try to load a swf. I'm guessing these are Morph targets blowing up the parser. I have shared an example FLA and SWF here which cause the problems. I can't actually find the frame that is causing the problem.
FLA: http://dl.dropbox.com/u/224564/problemAsset.fla
SWF: http://dl.dropbox.com/u/224564/problemAsset.swf
Error: Unknown fill style type: 0x13
at com.codeazur.as3swf.data::SWFMorphFillStyle/parse()[C:\Users\hclark\popcap\sb-trinket-tool\src\com\codeazur\as3swf\data\SWFMorphFillStyle.as:48]
at com.codeazur.as3swf.data::SWFMorphFillStyle()[C:\Users\hclark\popcap\sb-trinket-tool\src\com\codeazur\as3swf\data\SWFMorphFillStyle.as:22]
at com.codeazur.as3swf::SWFData/readMORPHFILLSTYLE()[C:\Users\hclark\popcap\sb-trinket-tool\src\com\codeazur\as3swf\SWFData.as:593]
at com.codeazur.as3swf.tags::TagDefineMorphShape2/parse()[C:\Users\hclark\popcap\sb-trinket-tool\src\com\codeazur\as3swf\tags\TagDefineMorphShape2.as:36]
at com.codeazur.as3swf::SWFTimelineContainer/parseTag()[C:\Users\hclark\popcap\sb-trinket-tool\src\com\codeazur\as3swf\SWFTimelineContainer.as:185]
at com.codeazur.as3swf::SWFTimelineContainer/parseTagsAsyncInternal()[C:\Users\hclark\popcap\sb-trinket-tool\src\com\codeazur\as3swf\SWFTimelineContainer.as:137]
at com.codeazur.as3swf::SWFTimelineContainer/parseTagsAsyncHandler()[C:\Users\hclark\popcap\sb-trinket-tool\src\com\codeazur\as3swf\SWFTimelineContainer.as:130]
I changed the code to not throw an error and I get the following style requests:
Encountered unknown fill style type: 0x13
Encountered unknown fill style type: 0xb5
Encountered unknown fill style type: 0xff
Encountered unknown fill style type: 0x31
Encountered unknown fill style type: 0xdb
Encountered unknown fill style type: 0x34
Encountered unknown fill style type: 0x8b
Encountered unknown fill style type: 0xd6
Encountered unknown fill style type: 0x34
Encountered unknown fill style type: 0x4e
Encountered unknown fill style type: 0x4
Encountered unknown fill style type: 0xd4
Encountered unknown fill style type: 0xce
Encountered unknown fill style type: 0x8c
Encountered unknown fill style type: 0x3
Encountered unknown fill style type: 0xc6
Encountered unknown fill style type: 0xa1
Encountered unknown fill style type: 0x63
Encountered unknown fill style type: 0x3e
Encountered unknown fill style type: 0x3e
Encountered unknown fill style type: 0x9d
Encountered unknown fill style type: 0x89
Encountered unknown fill style type: 0x1e
Encountered unknown fill style type: 0x86
Encountered unknown fill style type: 0xe8
Encountered unknown fill style type: 0xf1
Encountered unknown fill style type: 0x2
Encountered unknown fill style type: 0x58
Encountered unknown fill style type: 0x79
Encountered unknown fill style type: 0xff
Encountered unknown fill style type: 0xbd
Encountered unknown fill style type: 0xb2
Encountered unknown fill style type: 0x4f
Encountered unknown fill style type: 0x86
Encountered unknown fill style type: 0x86
Encountered unknown fill style type: 0x2b
Encountered unknown fill style type: 0x26
Encountered unknown fill style type: 0x5b
Encountered unknown fill style type: 0xff
Encountered unknown fill style type: 0x1b
Encountered unknown fill style type: 0x77
Encountered unknown fill style type: 0x3a
Encountered unknown fill style type: 0x31
Encountered unknown fill style type: 0xf7
Encountered unknown fill style type: 0xfd
Encountered unknown fill style type: 0x64
Encountered unknown fill style type: 0x70
Encountered unknown fill style type: 0x63
Encountered unknown fill style type: 0x7c
Encountered unknown fill style type: 0x7f
WARNING: parse error: Unknown fill style type: 0x35, Tag: DefineMorphShape2, Index: 15
how to write a definesprite to a swf?
Hi. Great piece of software! I'm trying to modify an embed text file with your library, but after publishing there is no change... My code:
package{
import com.codeazur.as3swf.SWF;
import com.codeazur.as3swf.SWFData;
import com.codeazur.as3swf.tags.TagDefineBinaryData;
import flash.display.Loader;
import flash.display.Sprite;
import flash.text.TextField;
import mx.core.ByteArrayAsset;
public class Test extends Sprite{
[Embed(source="test.txt",mimeType="application/octet-stream")] private var text:Class;
public function Test(){
var textField:TextField = new TextField();
textField.text = ByteArrayAsset(new text()).toString();
addChild(textField);
var swf:SWF = new SWF(root.loaderInfo.bytes);
trace(swf);
var tag:TagDefineBinaryData = swf.getCharacter(1) as TagDefineBinaryData;
trace(tag);
tag.binaryData.clear();
tag.binaryData.writeMultiByte("this is a new value", "iso-8859-1");
trace(tag);
var ba:SWFData = new SWFData();
swf.publish(ba);
var loader:Loader = new Loader();
loader.x = 200;
loader.loadBytes(ba);
addChild(loader);
}
}
}
override public function parse(data:SWFData):void {
dropShadowColor = data.readRGBA();
blurX = data.readFIXED();
blurY = data.readFIXED();
angle = data.readFIXED() ; // → angle = data.readFIXED() * 180 /Math.PI;
distance = data.readFIXED();
strength = data.readFIXED8();
var flags:uint = data.readUI8();
innerShadow = ((flags & 0x80) != 0);
knockout = ((flags & 0x40) != 0);
compositeSource = ((flags & 0x20) != 0);
passes = flags & 0x1f;
}
effect: get filter can not get correct dropShadowFilter
override public function get filter():BitmapFilter {
return new DropShadowFilter(
distance,
angle, // need angle not radian
ColorUtils.rgb(dropShadowColor),
ColorUtils.alpha(dropShadowColor),
blurX,
blurY,
strength,
passes,
innerShadow,
knockout
);
}
thank you for the amazing project!
sorry for my bad english...
PS:如果你懂得中文...
以下为错误的中文简述:
在com.codeazur.as3swf.data.filters.FilterDropShadow类中
函数parse 读到的angle 是弧度值
在as3 中 DropShadowFilter 使用的是角度值
将angle 换算为角度值 才能得到正确的 BitmapFilter
filter包下的其他类 我没有尝试
感谢你 分享这么棒的 代码
以上问题 是我今天下载的 ZIP 中 遇到的
Hi Claus,
I stumbled on a problem with SWFShape.export()
The problem being that "fills" are exported first and the "strokes" after that.
This gives z-sort problems between fill / stroke when the shape for example contains multiple overlapping filled and stroked rectangles. The current export seems to assume that a Shape contains only a single primitive.
Maybe better if DefaultShapeExporter would have a method like:
beginStyle ( lineStyle, fillStyle )
beginPath()
...
endPath()
So exporters know both lineStyle and fillStyle for the current path? (just thinking aloud)
=> with benefit of not needing SWFShape::exportLinePath() ;-)
Maybe I'm missing something, if so ignore.
Regards,
Tim
Text are not being rebuilt properly.
I created an swf with a text on it, (static/dynamic) and rebuilt the swf without touching anything.
Text came out wrong.
_bitmap = _loader.contentLoaderInfo.content as Bitmap;
_onCompleteCallback(_bitmap);
or
_onCompleteCallback(_bitmap.bitmapData);
So, lets load as2 swf
var ldr:URLLoader = e.target as URLLoader;
parsedSWFBytes = ldr.data;
// do nothing re-publish it only
var swf:SWF = new SWF (parsedSWFBytes);
parsedSWFBytes = new ByteArray();
swf.publish(parsedSWFBytes);
// load it with loader.loadBytes or save FileReference
Buttons had on (release) handler don't work. checked both swfs (original and saved) with Swix and not found any differences.. if open in Swix saved with Filereference swf - and save it from Swix - buttons work as usual
When generating a matrix from Matrix.createBox the rotation value needs to be in radians
in SWFShape line 408:
matrix.createBox(m.xscale / 20, m.yscale / 20, m.rotation, m.translateX / 20, m.translateY / 20);
the value is defined in degree's
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.