how to access external SWF clips?

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

how to access external SWF clips?

sledorze
Hi!
I'm more used to haxe than Flash so maybe the answer to this question is obvious to many of you (I hope so).
I have a swf which contains some Clips (I've seen those using Sothink SWF decompiler and also reading the swf through the SWF reader of the format library).

I've read that usually, we can instantiate sprite using some class name.
It does not looks like this swf defines any class name :(

I've seen that the SWF format defines TSymbolClass( symbols : Array<SymData> ); containing SymData of the form;

typedef SymData = {
        cid : Int,
        className : String
}

I am now wondering if I need to find my clips and then create an entry in this SymData, reserialize the SWF
and (I don't know how) make it reload from memory in some way..

But maybe I am completly wrong taking this approach..
..can you gimme some feedback (I would appreciate)?

Thanks,
Stéphane
Reply | Threaded
Open this post in threaded view
|

Re: how to access external SWF clips?

sledorze
Ok, I've added the TSymbolClass

                        swf.tags.push(
                                TSymbolClass(  [{cid : 153, className : cochonClassName }] )
                        );

and reload the rewritten swf

                        var bOutput = new BytesOutput();
                        var writer = new Writer(bOutput);
                        writer.write(swf);
                        loader.loadBytes(bOutput.getBytes().getData());

I can see that the new tag is present :)
but still, trying to retrieve it fails with a ReferenceError

  var externDef : Dynamic = info.applicationDomain.getDefinition(cochonClassName);

So maybe something stupid is missing or the whole approach is wrong..
Any advice?

Thanks,
Stephane
Reply | Threaded
Open this post in threaded view
|

Re: how to access external SWF clips?

Jan_Flanders


On Sun, Sep 11, 2011 at 12:27 AM, sledorze <[hidden email]> wrote:
Ok, I've added the TSymbolClass

                       swf.tags.push(
                               TSymbolClass(  [{cid : 153, className : cochonClassName }] )
                       );

and reload the rewritten swf

                       var bOutput = new BytesOutput();
                       var writer = new Writer(bOutput);
                       writer.write(swf);
                       loader.loadBytes(bOutput.getBytes().getData());

I can see that the new tag is present :)
but still, trying to retrieve it fails with a ReferenceError

 var externDef : Dynamic =
info.applicationDomain.getDefinition(cochonClassName);

So maybe something stupid is missing or the whole approach is wrong..
Any advice?

Thanks,
Stephane


--
View this message in context: http://haxe.1354130.n2.nabble.com/how-to-access-external-SWF-clips-tp6779629p6779665.html
Sent from the Haxe mailing list archive at Nabble.com.

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

The SymbolClass tag only forms the link between a symbol(id) and a class(name). You linked it to an existing symbol but apparently there exists no class with the name you supplied. The bytecode of that class needs to be present inside a DoABC or DefineABC tag. You can add the ActionscriptByteCode to the loaded swf, or you could also create the class in your haxe script. The moment the player encounters the symbol class tag it will look for the class in the applicationDomain into which you loaded the swf.
If you load into the same applicationDomain a simple "class CochonClassName extends flash.display.MovieClip{};" should work. (mind the uppercase in that case :)  )

Jan


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

Re: how to access external SWF clips?

sledorze
Thanks Jan,

I've just tried to create a class and access it;
It works, I can create the instance and attach it to the Lib.current but nothing displays.. (and looking at the number of frames it defines, it is clear that it is not an instance of the clip in the swf).

while looking at swf output, I've also noticed that in fact, the clips I am looking for are referenced by some TExport tags..
I wonder how to load those; are they different from classes?
(The swf is loaded as a AVM1Movie, so is not AS3, perhaps this could change how to access it??)

Thanks for helping!..
Stephane


On Sun, Sep 11, 2011 at 2:52 AM, Jan_Flanders [via Haxe] <[hidden email]> wrote:


On Sun, Sep 11, 2011 at 12:27 AM, sledorze <[hidden email]> wrote:
Ok, I've added the TSymbolClass

                       swf.tags.push(
                               TSymbolClass(  [{cid : 153, className : cochonClassName }] )
                       );

and reload the rewritten swf

                       var bOutput = new BytesOutput();
                       var writer = new Writer(bOutput);
                       writer.write(swf);
                       loader.loadBytes(bOutput.getBytes().getData());

I can see that the new tag is present :)
but still, trying to retrieve it fails with a ReferenceError

 var externDef : Dynamic =
info.applicationDomain.getDefinition(cochonClassName);

So maybe something stupid is missing or the whole approach is wrong..
Any advice?

Thanks,
Stephane


--
View this message in context: http://haxe.1354130.n2.nabble.com/how-to-access-external-SWF-clips-tp6779629p6779665.html
Sent from the Haxe mailing list archive at Nabble.com.

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

The SymbolClass tag only forms the link between a symbol(id) and a class(name). You linked it to an existing symbol but apparently there exists no class with the name you supplied. The bytecode of that class needs to be present inside a DoABC or DefineABC tag. You can add the ActionscriptByteCode to the loaded swf, or you could also create the class in your haxe script. The moment the player encounters the symbol class tag it will look for the class in the applicationDomain into which you loaded the swf.
If you load into the same applicationDomain a simple "class CochonClassName extends flash.display.MovieClip{};" should work. (mind the uppercase in that case :)  )

Jan


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


If you reply to this email, your message will be added to the discussion below:
http://haxe.1354130.n2.nabble.com/how-to-access-external-SWF-clips-tp6779629p6779797.html
To unsubscribe from how to access external SWF clips?, click here.



--
Stéphane Le Dorze


Reply | Threaded
Open this post in threaded view
|

Re: how to access external SWF clips?

Jan_Flanders


On Sun, Sep 11, 2011 at 10:55 AM, sledorze <[hidden email]> wrote:

while looking at swf output, I've also noticed that in fact, the clips I am looking for are referenced by some TExport tags..

Script number 2 in this post: http://haxe.1354130.n2.nabble.com/haXer-tools-was-BootLoader-td5438798.html should fix that.
Also make sure that the swf you load, has a FileAttributes tag (TSandbox in format.swf) with the AS3-flag set to true, otherwise the FlashPlayer will ignore all AS3-specific tags like DoABC, DefineABC and SymbolClass).
I'm not sure the script injects that tag since it was meant for swf's that are to be used with -swf-lib and the haxe-compiler does not seem to mind if it lacks. If you have to inject the TSandbox tag, make sure it is the very first tag, right after the header, or the FlashPlayer will again default to AS2.

Jan

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

Re: how to access external SWF clips?

sledorze
On my way with son to the swimming pool; Will Check that this evening.. Thanks jan!

Sent from my iPhone

On 11 sept. 2011, at 14:03, "Jan_Flanders [via Haxe]" <[hidden email]> wrote:



On Sun, Sep 11, 2011 at 10:55 AM, sledorze <[hidden email]> wrote:

while looking at swf output, I've also noticed that in fact, the clips I am looking for are referenced by some TExport tags..

Script number 2 in this post: http://haxe.1354130.n2.nabble.com/haXer-tools-was-BootLoader-td5438798.html should fix that.
Also make sure that the swf you load, has a FileAttributes tag (TSandbox in format.swf) with the AS3-flag set to true, otherwise the FlashPlayer will ignore all AS3-specific tags like DoABC, DefineABC and SymbolClass).
I'm not sure the script injects that tag since it was meant for swf's that are to be used with -swf-lib and the haxe-compiler does not seem to mind if it lacks. If you have to inject the TSandbox tag, make sure it is the very first tag, right after the header, or the FlashPlayer will again default to AS2.

Jan

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


If you reply to this email, your message will be added to the discussion below:
http://haxe.1354130.n2.nabble.com/how-to-access-external-SWF-clips-tp6779629p6780609.html
To unsubscribe from how to access external SWF clips?, click here.
Reply | Threaded
Open this post in threaded view
|

Re: how to access external SWF clips?

sledorze
In reply to this post by Jan_Flanders
Mmmmmmm.. looks like useAS3 is present in NME format.swf.Data file:

        TSandBox( useDirectBlit : Bool, useGpu : Bool, hasMeta: Bool, useAs3: Bool, useNetwork: Bool);

but not from the one in format library:

        TSandBox( v : Int );

I just found I maybe not using the right one..
..start to wonder a lot on many variables.. (gulps!)

I start to think I should start at the begining and learn the basics first; best pointer on flash principles regarding all this? (AS2 and AS3 approachs)

Stephane

Reply | Threaded
Open this post in threaded view
|

Re: how to access external SWF clips?

sledorze
Ok, I used the two scripts in order to set the flasg and generate the symbols :)
However, was not working.. :\
Then I suspected the names starting with a lowercase as you said it was important (but not sure if you were talking about uppercase or consistency).
So I've patched the scripts to generate uppercase versions..

And then something strange has happened.. the swf loading is simply cancelled by the browser (chrome) without giving much information (no callback called).

However, tryng in FireFox; it works!!! amazing :)

I'll try to shrink to see what extra steps were not really requiered.

I'll also try to figure out why chrome is cancelling this loading.. (I think it may be due to security ... not sure - I you have any idea, don't hesitate!)

Thanks Jan! it was very instructive :)

Stéphane

On Sun, Sep 11, 2011 at 6:45 PM, sledorze [via Haxe] <[hidden email]> wrote:
Mmmmmmm.. looks like useAS3 is present in NME format.swf.Data file:

        TSandBox( useDirectBlit : Bool, useGpu : Bool, hasMeta: Bool, useAs3: Bool, useNetwork: Bool);

but not from the one in format library:

        TSandBox( v : Int );

I just found I maybe not using the right one..
..start to wonder a lot on many variables.. (gulps!)

I start to think I should start at the begining and learn the basics first; best pointer on flash principles regarding all this? (AS2 and AS3 approachs)

Stephane




If you reply to this email, your message will be added to the discussion below:
http://haxe.1354130.n2.nabble.com/how-to-access-external-SWF-clips-tp6779629p6781188.html
To unsubscribe from how to access external SWF clips?, click here.



--
Stéphane Le Dorze


Tel: <a href="tel:%2B33%20%280%29%206%2008%20%C2%A076%2070%2015" value="+33608767015" target="_blank">+33 (0) 6 08  76 70 15