(To download, check out the Links to libraries and tools necessary to build SSWF pages)
Especially, it hides from you the need to know whether you should use a DefineFont or DefineFont2. Depending on the information that you put in a TagFont object, the library will know which of DefineFont or DefineFont2 will be required for your movie.
The library also takes care of selecting different tags depending on the version of the output movie. For instance, the ProtectDebug tag can only be used with version 5. Before version 5, you need a Protect tag and after, you need a ProtectDebug2. Similarly, since version 8 you need a FileAttributes tag at the very beginning of the movie.
Because the available version of the player may be constrained, you can also specify what minimum and maximum version of a movie you want.
At this time SSWF supports all of version 7, except the Video and the streaming sound tags. It can also create a proper version 8 by adding the FileAttributes and the Import2 instead of Import as required by the specification. Other version 8 tags will come soon.
To get started, look inside the samples directory. It includes samples of SSWF and C++ code. The SSWF compiler can be looked at (especially the sswf_save.c++ file) as a good example on how to use the SSWF library.
SSWF is a C++ library ready to be used on your Unix system. It also includes a set of pre-compiled libraries which run under Microsoft Windows. Though, I do not offer support for Visual Studio, many have successfully compiled the library with it. So it is possible. Once in a while I do check to see whether cl likes my code. In general, it does. Note that all the code works perfectly with g++ and should work with any compatible compiler.
The packages I offer work on the following platforms:
Some people out there made the library work for:
You may have a look at the C samples in:
The C programmers are invited to look inside the header file:
This lists all the available enumerations, structures and functions one needs to create an SSWF movie. The use is very object oriented. The main thing is that all the objects need to be created on the heap and destroyed once done with them. It may be a bit tedious, but that's why you should maybe consider using C++ one day...
The following shows you how to create a TagHeader, set the minimum version and add a Sprite to it before saving the program.
#include <sswf/libsswf_c.h> ... struct SSWF_TagHeader *header; struct SSWF_TagSprite *sprite; struct SSWF_Data *data; void *buffer; size_t size; header = sswf_tag_header_create(); sswf_tag_header_set_minimum_version(header, 5); sprite = sswf_tag_sprite_create(sswf_tag_header_cast_tag_base(header)); ... -- initialize the sprite ... -- add other objects data = sswf_data_create(); sswf_tag_header_save(header, data); sswf_data_read(data, &buffer, &size); f = fopen("a.swf", "w"); fwrite(buffer, 1, size, f); fclose(f); sswf_tag_header_destroy(header);
As you can see, this is pretty straight forward, just somewhat more text to type (feel free to copy & paste!)
The naming convention is as follow:
All of these structures can be put on the stack. You are responsible to initialize them properly (just like their counter part in C++).
The cpp-to-c generator creates several special functions to (1) create, (2) destroy and (3) cast the object pointers. The cast is very important since C casting can result in the wrong C++ pointer.
The parameters to each function is either kept the same (standard C type such as int, char, etc.), tweaked to work in C (i.e. the C++ library makes use of the type bool which is transformed to an int in the C library.) or, for objects, enumerations and structures, are renamed with their C name.
The result looks like this:
<return type> sswf_<class name>_<function>(<parameters>);
I suggest you look at a few object in the C and the C++ headers to compare. It is rather easy to see what happens to the names.
The C++ constructor is transformed into:
void sswf_<class name>_create(<parameters>);
The C++ destructor is transformed into:
void sswf_<class name>_destroy(ClassName *ojbect);
The casts (which are only static casts in C++, thought I have to use reinterpret from the C pointer to the C++ pointer and vice versa!):
<inherited class name> sswf_<class name>_cast_<inherited class name>(<class name>);
Once you understand how this works, you can read the C++ documentation even when you are working with the C library. In the first code sample, I use sswf_tag_sprite_create() which is the Constructor of the sswf::TagSprite object.