Made to Order Software Corporation Logo

libsswf: sswf::TagDoAction Class Reference

This tag hold an ActionScript. More...

#include <libsswf.h>

Inheritance diagram for sswf::TagDoAction:

:TagBase :MemoryManager

List of all members.


Public Member Functions

VectorsActions (void)
 Retrieve a reference to the actions array.
virtual ErrorManager::error_code_t Save (Data &data)
 Save the TagDoAction in the specified Data buffer.
void SetAction (const Action &action)
 Append one action.
void SetSprite (sswf_id_t sprite)
 Set the sprite reference identifier.
 TagDoAction (TagBase *parent)
 Initialize a TagDoAction.
virtual swf_type_t TypeFlags (void) const
 Returns the type flags of a TagDoAction.

Private Member Functions

virtual ErrorManager::error_code_t ParseTag (swf_tag_t tag, const Data &data)
 Parse data from a file into a DoAction tag.
virtual ErrorManager::error_code_t PreSave (void)
 Determine the minimum version required to save this tag.

Private Attributes

Vectors f_actions
sswf_id_t f_sprite

Detailed Description

This tag represents an ActionScript in binary form.

An ActionScript is executed each time the given frame is played back unless a Sprite identifier is specified, in that case the ActionScript is an initialization script an thus it will be run only once.

See also:
SWF_TAG_DO_ACTION

SWF_TAG_DO_INIT_ACTION

SWF Alexis' Reference—DoAction

SWF Alexis' Reference—DoInitAction

SWF Alexis' Reference—swf_tag


Constructor & Destructor Documentation

TagDoAction::TagDoAction ( TagBase parent  ) 

The constructor assumes that there is no actions and no sprite reference to this tag.

Parameters:
parent The parent of this TagDoAction

References sswf::assert(), and f_sprite.


Member Function Documentation

Vectors & sswf::TagDoAction::Actions ( void   )  [inline]

This function can be used to retrieve a reference to the array used to save all the actions.

You can then add the actions you create to this array. You most certainly will want to save a sswf::Action::Duplicate(void) const and use the sswf::MemoryManager::MemAttach(MemBuffer *ptr, size_t size, const char *info) function to attach these duplicates to your sswf::TagDoAction object.

The main idea in letting you have direct access to the array is for you to be able to manage the list they way you want: you can then insert new actions anywhere, append them, delete them...

Returns:
A Vectors reference of all the actions in this TagDoAction object.
See also:
SetAction(const Action& action)

References f_actions.

ErrorManager::error_code_t TagDoAction::ParseTag ( swf_tag_t  tag,
const Data data 
) [private, virtual]

This function reads the actions saved in the DoAction tag.

Parameters:
[in] tag The tag that generated this call
[in] data The Data buffer from the Flash file being loaded
Returns:
An error if one occurs, or ErrorManager::ERROR_CODE_NONE

Implements sswf::TagBase.

References sswf::ErrorManager::ERROR_CODE_NONE, f_actions, f_sprite, sswf::Data::GetShort(), sswf::Action::ParseList(), and sswf::TagBase::SWF_TAG_DO_INIT_ACTION.

ErrorManager::error_code_t TagDoAction::PreSave ( void   )  [private, virtual]

This function checks whether a sprite referenced was defined; if so, then the minimum version is set to 6.

Then it goes through the whole list of actions recursively to determine what the required minimum version is to save these actions.

Returns:
An error code if something goes wrong
See also:
sswf::Action::MinimumListVersion(const Vectors& list)

Reimplemented from sswf::TagBase.

References sswf::ErrorManager::ERROR_CODE_NONE, f_actions, f_sprite, sswf::Action::MinimumListVersion(), and sswf::TagBase::MinimumVersion().

ErrorManager::error_code_t TagDoAction::Save ( Data data  )  [virtual]

This function saves the TagDoAction in the specified Data buffer.

This means saving the list of actions and, when specified, the reference to the given sprite.

The list of actions is saved using the sswf::Action::SaveList(TagBase *parent, const Vectors *list, Data& data, const Vectors *extra) function.

Returns:
An error code if something goes wrong
See also:
sswf::Action::SaveList(TagBase *parent, const Vectors *list, Data& data, const Vectors *extra)

Implements sswf::TagBase.

References sswf::Data::Append(), sswf::Data::ByteSize(), sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NONE, f_actions, f_sprite, sswf::Vectors::Get(), sswf::Data::PutShort(), sswf::Action::SaveList(), sswf::TagBase::SaveTag(), sswf::TagBase::SWF_TAG_DO_ACTION, and sswf::TagBase::SWF_TAG_DO_INIT_ACTION.

void TagDoAction::SetAction ( const Action action  ) 

First create some action, then append the action using this function.

The new action is added at the very end. The input action is duplicated internally and thus the input can be modified by the caller afterward.

For more control over the list of actions, use the Actions() function to retrieve the vector and manage the vector yourself.

Warning:
If you manage the vector of actions yourself, you should be careful and use the MemAttach() function of your TagDoAction() to make sure that the memory allocated by each action is released at the time the TagDoAction() is destroyed. Once added to the actions vector of a TagDoAction(), the actions become the property of the TagDoAction() object.
Parameters:
action The action to duplicate and append at the end of the list
See also:
sswf::TagDoAction::Actions(void)

References sswf::Action::Duplicate(), f_actions, sswf::MemoryManager::MemAttach(), and sswf::Vectors::Set().

void TagDoAction::SetSprite ( sswf_id_t  sprite  ) 

This function saves the specified identifier as a sprite identifier or set to zero to remove the reference.

When a sswf::TagDoAction has a reference to a sprite, it because the ActionScript to execute once to initialize the Sprite it references (Similar to a constructor in C++).

By default, a TagDoAction has no sprite reference.

Parameters:
sprite The identifier of the sprite to reference

References f_sprite.

TagBase::swf_type_t TagDoAction::TypeFlags ( void   )  const [virtual]

This function returns CONTROL since an ActionScript is viewed as a control tag and not a definition.

It returns SCRIPT since obviously it includes a script.

It returns ONE because you are supposed to have only one per frame. This is not really enforced by the players.

It returns REFERENCE thought if you do not define a sprite reference this is obviously not the case.

Returns:
A set of swf_type_t flags

Implements sswf::TagBase.

References SWF_TYPE_CONTROL, SWF_TYPE_ONE, SWF_TYPE_REFERENCE, and SWF_TYPE_SCRIPT.


Member Data Documentation


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


Generated on Wed Mar 18 15:13:59 2009 for libsswf by  doxygen 1.5.5