need format.swf help

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

need format.swf help

go2ghana
Hi,
in order to use graphic assets created with ming library from AS3
movieclips made with haXe
I found that this is possible with the swf format lib: I only needed to
change the TSandBox.useAs3 to true
and then can load the result with Loader.loadBytes into my clip where
all the named displayobjects defined
with ming can be displayed with addChild then.
So far nice but if I want to reuse any object I need a way to duplicate
it. Therefore I tried to export the symbol with ming
and add the appropriate class definition while converting to AS3 similar
to the way used in SamHaXe:

....
case TExportAssets(symbols):
                 trace(t);
                 if(frame_symbols == null)
                     frame_symbols = new Array<{cid: Int, className:
String}>();
                 for (s in symbols)
                 {
                     trace(Std.string(s));
                     if (symbolNames.exists(s.className.ucFirst() ))
                     {
                         trace('oops duplicate class:' +
s.className.ucFirst() );
                         continue;
                     }
                     symbolNames.set(s.className.ucFirst(), 1);
                     frame_symbols.push( { cid:s.cid,
className:s.className.ucFirst() } );
                     var ctx = getContext();
                     var cl = ctx.beginClass(s.className.ucFirst(), true);
                     cl.superclass = ctx.type('flash.display.Shape');
                     ctx.endSubClass();
                 }
                 case TShowFrame():
                 //WRITE SYMBOLS LOADED IN CURRENT FRAME
                 if (frame_symbols != null)
                 {
                     trace('writing frame_symbols:' +
frame_symbols.length + ' ' + Std.string(frame_symbols[0]) + ' ...');
                     swf_writer.writeTag(TSymbolClass(frame_symbols));
                 }
                 //WRITE CLASSES GENERATED FROM SYMBOLS LOADED IN
CURRENT FRAME
                 if(frame_as3 != null) {
                     frame_as3.finalize();
                     trace('writing frame classes');
                     var abc = new haxe.io.BytesOutput();
                     trace(Std.string(frame_as3.getData().classes));
                     format.abc.Writer.write(abc, frame_as3.getData());
                     swf_writer.writeTag(TActionScript3(abc.getBytes()));
                 }
                 swf_writer.writeTag(t);
                 frame_as3 = null;
                 frame_symbols = null;
...

but I was not able to figure out how I have to associate the class
definition to use the symbol id
therefore I can later instantiate the i.e. 'Circle' Class (superclass
Shape) and add it to a DisplayObjectContainer
but it keeps empty (width and height = 0)
Any ideas how I can get the classes use the exported symbols?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: need format.swf help

Nicolas Cannasse
Le 08/04/2011 07:44, Axel Huizinga a écrit :
> but I was not able to figure out how I have to associate the class
> definition to use the symbol id

It's in the TSymbolClass : you have both className and "cid", which is
the symbol id (or 0 for "root class")

Also, make sure that you generate your classes before adding TSymbolClass.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: need format.swf help

go2ghana
Am 08.04.2011 10:57, schrieb Nicolas Cannasse:

> Le 08/04/2011 07:44, Axel Huizinga a écrit :
>> but I was not able to figure out how I have to associate the class
>> definition to use the symbol id
>
> It's in the TSymbolClass : you have both className and "cid", which is
> the symbol id (or 0 for "root class")
>
> Also, make sure that you generate your classes before adding
> TSymbolClass.
>
> Best,
> Nicolas
>

Tried it accordingly afaik but I still have no success. How can I trace
if the association of the generated class with the symbols is correct?
Will this work at all with an Export originally created within an AVM1 swf?

my code traces:
AS2Loader:parseSWF:90: TExportAssets([{ cid : 1, className : Circle }])

AS2Loader:parseSWF:95: { cid : 1, className : Circle }

AS2Loader:parseSWF:113: writing frame classes

AS2Loader:parseSWF:115: [{ namespace : null, constructor : Idx(2),
statics : Idx(1), fields : [], is
Final : false, isSealed : false, superclass : Idx(4), isInterface :
false, staticFields : [], interf
aces : [], name : Idx(2) }]

AS2Loader:parseSWF:124: writing frame_symbols:1 { cid : 1, className :
Circle } ...

SWF:bytesComplete:75: instance2:0

SWF:bytesComplete:84: assetClass:[class Circle]

SWF:bytesComplete:86: [object Circle] SuperClass ->[class Sprite]

SWF:bytesComplete:88:
instance3 depth:1 alpha:1 x:0 y:0 width:0 height:0
rotation:0 scaleX:1 scaleY:1 visible:true
  parentBox:(x=6710886.4, y=6710886.4, w=0, h=0)
  rootBox:(x=6710886.4, y=6710886.4, w=0, h=0)

The complete source and the ming generated exporting swf is available at
http://localhost/go2ghana.net/httpdocs/flashDevel/src.zip


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: need format.swf help

Jan_Flanders
In reply to this post by go2ghana


On Fri, Apr 8, 2011 at 7:44 AM, Axel Huizinga <[hidden email]> wrote:
Hi,
.... 
                 cl.superclass = ctx.type('flash.display.Shape');
                   ctx.endSubClass();
               }
Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org

With regard to:  cl.superclass = ctx.type('flash.display.Shape');
A DefineShape tag in a swf cannot be linked to a class extending flah.display.Shape. Tags/classes that can be linked are:

flash.display.BitmapData
flash.display.Bitmap
flash.display.Sprite
flash.display.MovieClip
flash.display.SimpleButton
flash.utils.ByteArray
flash.media.Sound
flash.text.Font

Jan

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: need format.swf help

Jan_Flanders
In reply to this post by go2ghana


On Fri, Apr 8, 2011 at 1:38 PM, Axel Huizinga <[hidden email]> wrote:
Am 08.04.2011 10:57, schrieb Nicolas Cannasse:
Tried it accordingly afaik but I still have no success. How can I trace if the association of the generated class with the symbols is correct?
Will this work at all with an Export originally created within an AVM1 swf?

Maybe 'tool2' in this post can help:
http://haxe.1354130.n2.nabble.com/haXer-tools-was-BootLoader-td5438798.html

For the abc creation you could also use plain haxe instead of format.abc:
-List the exported symbols and which tag type they are linked to
-Write the corresponding classes in a .hx file
-Compile them with -swf-lib library.swf (where library.swf would be what tool2 in the link above outputs: tags+symbolclass(es), but no abc)

Jan


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: need format.swf help

go2ghana
Am 08.04.2011 13:56, schrieb Jan Flanders:

>
>
> On Fri, Apr 8, 2011 at 1:38 PM, Axel Huizinga <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Am 08.04.2011 10:57, schrieb Nicolas Cannasse:
>     Tried it accordingly afaik but I still have no success. How can I
>     trace if the association of the generated class with the symbols
>     is correct?
>     Will this work at all with an Export originally created within an
>     AVM1 swf?
>     http://haxe.org
>
>
> Maybe 'tool2' in this post can help:
> http://haxe.1354130.n2.nabble.com/haXer-tools-was-BootLoader-td5438798.html
>
> For the abc creation you could also use plain haxe instead of format.abc:
> -List the exported symbols and which tag type they are linked to
> -Write the corresponding classes in a .hx file
> -Compile them with -swf-lib library.swf (where library.swf would be
> what tool2 in the link above outputs: tags+symbolclass(es), but no abc)
>
> Jan
>
Perfect - thanks,
Axel

--
haXe - an open source web programming language
http://haxe.org