Standalone SWF files using the format.abc library?

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

Standalone SWF files using the format.abc library?

alstrup
Hi,

Does anyone know how to produce a stand-alone .swf file using the format.abc library?

Regards,
Asger Ottar Altrup


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

Re: Standalone SWF files using the format.abc library?

Nicolas Cannasse
Le 15/08/2011 14:00, Asger Ottar Alstrup a écrit :
> Hi,
>
> Does anyone know how to produce a stand-alone .swf file using the
> format.abc library?

Check http://haxe.org/com/libs/format/abc

Nicolas


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

Re: Standalone SWF files using the format.abc library?

alstrup
On Mon, Aug 15, 2011 at 2:57 PM, Nicolas Cannasse <[hidden email]> wrote:
Le 15/08/2011 14:00, Asger Ottar Alstrup a écrit :
Does anyone know how to produce a stand-alone .swf file using the
format.abc library?

Check http://haxe.org/com/libs/format/abc

I did, but it says that you have to use formats.swf to wrap the code and execute it. How is that done? 

And secondly, is it not possible to a complete .swf file that does not require formats.swf?

Regards,
Asger

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

Re: Standalone SWF files using the format.abc library?

Jan_Flanders


Le 15/08/2011 14:00, Asger Ottar Alstrup a écrit :
Does anyone know how to produce a stand-alone .swf file using the
format.abc library?

 
A simple example:

var ctx = new format.abc.Context();
//do all the abc writing
var abc = ctx.getData();

var abcOutput = new haxe.io.BytesOutput();
var abcWriter = format.abc.Writer(abcOutput);
abcWriter.write(abc);

var swf =
{
    header: {version:10, compressed:false, width:800, height:600, fps:30, nframes:1},
    tags:
    [
        TSandBox(8),
        TActionScript3(abcOutput.getBytes(), { id : 1, label : "Main" } ),
        TSymbolClass([{cid:0, className:"Main"}]),
        TShowFrame
    ]
};

var swfOutput = new haxe.io.BytesOutput();
var swfWriter = new format.swf.Writer(swfOutput);
swfWriter.write(swf);

var file = File.write("Main.swf",true);
file.write(swfOutput.getBytes());
file.close();

Cheers,
Jan

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

Re: Standalone SWF files using the format.abc library?

alstrup
Hi,

With a few changes, I got it to work:

import format.abc.Data;
import format.swf.Data;

class Main {
static function main() {
var ctx = new format.abc.Context();
ctx.finalize();
var abc = ctx.getData();

var abcOutput = new haxe.io.BytesOutput();
var abcWriter = new format.abc.Writer(abcOutput);
abcWriter.write(abc);

var swf =  {
header: { version:10, compressed:false, width:800, height:600, fps:30.0, nframes:1 },
tags:
[
TSandBox(8),
TActionScript3(abcOutput.getBytes(), { id : 1, label : "Main" } ),
TSymbolClass([{cid:0, className:"Main"}]),
TShowFrame
]
};

var swfOutput = new haxe.io.BytesOutput();
var swfWriter = new format.swf.Writer(swfOutput);
swfWriter.write(swf);

var file = neko.io.File.write("Main.swf",true);
file.write(swfOutput.getBytes());
file.close();
}
}

Next question: How can I link some existing haXe code with this? Let's say I have

class Hello {
static public function hello() {
trace("Hello world");
}
}

How can I compile that and link it with generated SWF code from above and generate code that calls Hello.hello?

Regards,
Asger


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