libsswf: sswf::TagImport Class Reference

# sswf::TagImport Class Reference

Import a set of object defined in another movie. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::TagImport:

List of all members.

## Public Member Functions
void | AddName (const char *name, const char *type)
| Add an object to import.
const char * | HasID (sswf_id_t id) const
| Search the name for a given identifier.
sswf_id_t | HasName (const char *name) const
| Search the identifier for a given name.
virtual ErrorManager::error_code_t | Save (Data &data)
| Pre-save all the children tags of this tag.
void | SetFilename (const char *filename)
| Filename of the original input movie.
void | SetURL (const char *url)
| Set the URL of the input movie.
| TagImport (TagBase *parent)
| Initialize the tag import object.
virtual swf_type_t | TypeFlags (void) const
| The type of the TagImport.
## Private Member Functions
virtual ErrorManager::error_code_t | ParseTag (swf_tag_t tag, const Data &data)
virtual ErrorManager::error_code_t | PreSave (void)
| Ensures the minimum version.
## Private Attributes
char * | f_filename
Vectors | f_objects
char * | f_url
## Classes
struct | import_t
| Defines each imported object identifier, name and type. More...

## Detailed Description

This object is used to declare a list of objects defined in another movie but are used in this movie.

The other movie must have a corresponding TagExport with the different names specified in this TagImport tag.

See also:
  sswf::TagExport

  SWF Alexis' Reference—Import

  SWF Alexis' Reference—swf_tag

## Constructor & Destructor Documentation

TagImport::TagImport | ( | TagBase * | parent | ) |

This object can be created with the TagHeader as a parent.

It expects a URL and Filename to know which other movie it is to load, and a list of the objects to load from that other movie.

Parameters:

  `[in]` | parent | The parent of the tag import

References f_filename, and f_url.

## Member Function Documentation

void TagImport::AddName | ( | const char * | name,
|  | const char * | type |
| ) |  |  |

This function adds one object by name to the list of objects to import. The name must be the same as the name found in the TagExport of the input movie.

The type is only informational and it is not saved in the Flash animation.

The identifier of the imported object is automatically assigned using the sswf::TagHeader::NextID() function. You can retrieve the identifier with the HasName() function after you added an object.

Parameters:

  `[in]` | name | The name of the object
  `[in]` | type | The type of the object

References sswf::TagImport::import_t::f_id, sswf::TagImport::import_t::f_name, f_objects, sswf::TagImport::import_t::f_type, sswf::TagBase::Header(), sswf::MemoryManager::MemAttach(), sswf::TagHeader::NextID(), sswf::Vectors::Set(), and sswf::MemoryManager::StrDup().

const char * TagImport::HasID | ( | sswf_id_t | id | ) | const

This function searches for an object with the specified identifier.

If the identifier is found, then the name is returned, otherwise NULL is returned.

Parameters:

  `[in]` | id | The identifier to search for

Returns:
  The corresponding name or NULL

References sswf::Vectors::Count(), sswf::TagImport::import_t::f_id, sswf::TagImport::import_t::f_name, f_objects, and sswf::Vectors::Get().

sswf_id_t TagImport::HasName | ( | const char * | name | ) | const

This function searches for an object with the given name.

If the name is found, then the corresponding identifier is returned otherwise it returns zero.

Parameters:

  `[in]` | name | The name of the object to search for

Returns:
  The corresponding identifier or zero

References sswf::Vectors::Count(), sswf::TagImport::import_t::f_id, sswf::TagImport::import_t::f_name, f_objects, and sswf::Vectors::Get().

virtual ErrorManager::error_code_t sswf::TagImport::ParseTag | ( | swf_tag_t | tag,
|  | const Data & | data |
| ) |  |  | `[private, virtual]`

Implements sswf::TagBase.

ErrorManager::error_code_t TagImport::PreSave | ( | void |  | ) | `[private, virtual]`

This function requests that the movie be at least of version 5.

Returns:
  ErrorManager::ERROR_CODE_NONE when no error occured, an error otherwise

Reimplemented from sswf::TagBase.

References sswf::ErrorManager::ERROR_CODE_NONE, and sswf::TagBase::MinimumVersion().

ErrorManager::error_code_t TagImport::Save | ( | Data & | data | ) | `[virtual]`

The Save() function is the one you want to call to save an SWF movie.

You may use the Save() on any tag, however, if you do so you need to properly initialize the system. For that purpose, you may want to look at the code in the TagHeader::Save(Data& data) function.

Otherwise, you simply have to call the Save() function of the TagHeader. That will save the entire movie with the smallest possible version (or fail if something cannot be saved with the present parameters.)

The TagHeader::Save() function first calls the PreSave() functions, the PreSave2ndPass() and then the Save() functions of all the children.

The other tag Save() function simply save the tag within the specified Data buffer. Note however that the TagSprite will also call the Save() function of all of its children. Yet it does not call the PreSave() functions.

The Save() function saves the movie in a Data buffer. Later you need to save that buffer on disk or some other medium.

Returns:
  Zero when the Save() succeeds, non-zero if it fails

See also:
  TagBase::PreSave()

  TagBase::PreSave2ndPass()

Implements sswf::TagBase.

References sswf::Data::Append(), sswf::Data::ByteSize(), sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagImport::import_t::f_id, sswf::TagImport::import_t::f_name, f_objects, f_url, sswf::Vectors::Get(), sswf::Data::PutByte(), sswf::Data::PutShort(), sswf::TagBase::SaveString(), sswf::TagBase::SaveTag(), sswf::TagBase::SWF_TAG_IMPORT, sswf::TagBase::SWF_TAG_IMPORT2, and sswf::TagBase::Version().

void TagImport::SetFilename | ( | const char * | filename | ) |

This filename is used to specify the original filename. This is not saved in the output Flash movie. A tool can use this name to also build the input movie. The access to the input movie must be defined using the SetURL() function.

Parameters:

  `[in]` | filename | The name of the file to compile to have an input movie

References f_filename, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().

void TagImport::SetURL | ( | const char * | url | ) |

This URL points to the input movie which exports the objects named in this TagImport. This is a hard coded URL as used on your server.

Parameters:

  `[in]` | url | The URL to load the movie from

References f_url, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().

TagBase::swf_type_t TagImport::TypeFlags | ( | void |  | ) | const`[virtual]`

The TagImport is of type SWF_TYPE_DEFINE.

Returns:
  SWF_TYPE_DEFINE

Implements sswf::TagBase.

References SWF_TYPE_DEFINE.

## Member Data Documentation

char* sswf::TagImport::f_filename`[private]`

Referenced by SetFilename(), and TagImport().

Vectors sswf::TagImport::f_objects`[private]`

Referenced by AddName(), HasID(), HasName(), and Save().

char* sswf::TagImport::f_url`[private]`

Referenced by Save(), SetURL(), and TagImport().

The documentation for this class was generated from the following files:

- libsswf.h
- libsswf_tag_import.c++