claus / as3swf

Low level Actionscript 3 library to parse, create, modify and publish SWF files.
MIT License
526 stars 127 forks source link

How to export Embeds ? #36

Closed doublefx closed 10 years ago

doublefx commented 10 years ago

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

doublefx commented 10 years ago

Ok, got it.

Actually, first, as3commons-reflect that I use to collect the dependencies of my workers hasn't got any methods / properties dedicated to Embeds. The compiler create a class for each embed, so, I had to find a way to collect and add them to my dependencies.

Secondly, I had, while collecting the TagExportAssets which the SWFSymbol's name corresponds to the Embed class name of my dependencies, remove the unsued SWFSymbol then once all collected loop on them to collect the corresponding IDefinitionTag linking the tagId with the characterId.

It would have been nice if the SWF class had a symbols:Vector.<SWFSymbol> property filled at parse time though.

Btw, if you know a better way to achieve the goal, I'm interested :-)