libsswf: sswf::TagButton Class Reference

# sswf::TagButton Class Reference

Create an active area. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::TagButton:

List of all members.

## Public Member Functions
Vectors & | Actions (void)
| Returns a reference to the actions array.
bool | AddEvent (Event *event)
| Add the specified event to the button tag.
virtual ErrorManager::error_code_t | Save (Data &data)
| Saves a button in the Data buffer.
void | SetAction (const Action &action)
| Append an action to the button.
void | SetMenu (bool menu=true)
| Set the menu flag.
bool | SetState (const State &state)
| Add a state to a button object.
| TagButton (TagBase *parent)
| Initializes a button tag object.
virtual swf_type_t | TypeFlags (void) const
| The flags representing the button tag type.
## Private Member Functions
virtual ErrorManager::error_code_t | ParseTag (swf_tag_t tag, const Data &data)
| Parse data from a file into a Button tag.
virtual ErrorManager::error_code_t | PreSave (void)
| Check that a button can be saved.
## Private Attributes
Vectors | f_actions
Vectors | f_events
bool | f_menu
bool | f_save_button2
Vectors | f_states

## Detailed Description

A TagButton is used to create an area which reacts to mouse clicks, tabs and the spacebar. When marked as a menu, it can also react to arrow keys.

To fully create a button, one can add actions (what happens when the user clicks on the button), events (what happens, in more details, when the user clicks) and different states (what happens when the mouse moves over and clicks on the button or not.)

See also:
  sswf::TagScalingGrid

  SWF Alexis' Reference—Define Button

  SWF Alexis' Reference—swf_tag

## Constructor & Destructor Documentation

TagButton::TagButton | ( | TagBase * | parent | ) |

This function initializes the button tag with an empty list of actions and states.

Parameters:

  `[in]` | parent | The TagHeader where the button is added

## Member Function Documentation

Vectors & TagButton::Actions | ( | void |  | ) |

This function returns a Vector reference to the internal array of actions.

This can be used to save the actions in any order as you need.

Returns:
  The reference to the actions array

See also:
  TagButton::SetAction(const Action& action)

References f_actions.

bool TagButton::AddEvent | ( | Event * | event | ) |

This function adds the specified event to the TagButton object.

An event is a set of flags determining the event triggers and a set of actions to execute when it happens.

As many events as you need can be added. However, the first event matching has its ActionScript executed and then the process stops (to be confirmed!)

Bug:
  If you add actions using SetAction() or Actions(), then they will be prepended to the first event that has the Event::CONDITION_POINTER_RELEASE_INSIDE flag turned on. If no event has that flag set, then these actions are appended at the end of the list with that condition.

Parameters:

  `[in]` | event | The event to add to this TagPlace object

Returns:
  This function returns true if the event is accepted as is. If the event has flags which are not compatible with the TagButton tag, then the function returns false and the event is not added.

References sswf::Event::Events(), f_events, sswf::Vectors::Set(), and SSWF_EVENT_CONDITIONS.

Referenced by ParseTag().

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

This function reads the password saved in the Button tag.

Note that the password is kept encrypted.

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::Event::Actions(), AddEvent(), sswf::ErrorManager::ERROR_CODE_END_OF_STATES, sswf::ErrorManager::ERROR_CODE_NONE, f_actions, f_menu, f_save_button2, sswf::Data::GetByte(), sswf::Data::GetShort(), sswf::TagBase::Header(), sswf::Data::IsEndOfData(), sswf::MemoryManager::MemAttach(), sswf::State::Parse(), sswf::TagScalingGrid::ParseGridTag(), sswf::TagBaseID::ParseID(), sswf::Action::ParseList(), sswf::Event::SetConditions(), SetState(), sswf::TagBase::SWF_TAG_DEFINE_BUTTON2, and sswf::TagBase::SWF_TAG_DEFINE_SCALING_GRID.

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

This function traverse the list of events and actions to determine the minimum version and make sure that the events are valid.

Returns:
  An error_code_t error or ERROR_CODE_NONE

Reimplemented from sswf::TagBase.

References sswf::Event::Actions(), sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NO_STATES, sswf::ErrorManager::ERROR_CODE_UNEXPECTED_EVENT_FLAG, sswf::Event::Events(), f_actions, f_events, f_menu, f_save_button2, f_states, sswf::Vectors::Get(), sswf::TagScalingGrid::GridPreSave(), sswf::State::HasColorTransform(), sswf::Action::MinimumListVersion(), sswf::TagBase::MinimumVersion(), sswf::TagBase::OnError(), and SSWF_EVENT_CONDITIONS.

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

This function saves the button in the specified data buffer.

It can save button version 1 and 2.

The function will generate an error if it detects an invalid event (i.e. an event with all flags set at zero or invalid flags set.) If no event has the hit test bit set, an error is generated, but the save goes on.

Parameters:

  `[in]` | data | The data buffer where the button is saved

Implements sswf::TagBase.

References sswf::Action::ACTION_END, sswf::Event::Actions(), sswf::Data::Append(), sswf::Data::ByteSize(), sswf::Event::CONDITION_POINTER_RELEASE_INSIDE, sswf::Event::Conditions(), sswf::Vectors::Count(), sswf::Data::Empty(), sswf::ErrorManager::ERROR_CODE_BUTTON_MISSING_STATE, sswf::ErrorManager::ERROR_CODE_NONE, f_actions, f_events, f_menu, f_save_button2, f_states, sswf::Vectors::Get(), sswf::State::GetFlags(), sswf::TagScalingGrid::GridSave(), sswf::TagBaseID::Identification(), sswf::TagBase::OnError(), sswf::Data::PutByte(), sswf::Data::PutShort(), sswf::State::Save(), sswf::TagBaseID::SaveID(), sswf::Action::SaveList(), sswf::TagBase::SaveTag(), sswf::State::STATE_FLAG_HIT_TEST, sswf::TagBase::SWF_TAG_DEFINE_BUTTON, and sswf::TagBase::SWF_TAG_DEFINE_BUTTON2.

void TagButton::SetAction | ( | const Action & | action | ) |

This function adds one action at the end of the list of actions of the button. If you want to manage the list better, use the Actions() function to get access to the array of actions.

The input action is copied and thus it can be modified on return.

Parameters:

  `[in]` | action | The action to append; it is copied in the array

Returns:
  TagButton::Actions(void)

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

void TagButton::SetMenu | ( | bool | menu = `true` | ) |

This function is used to set the menu flag of the button.

A button with the menu flag turned on can be used to select an entry as if it were a menu.

Parameters:

  `[in]` | menu | The new state of the menu flag (true or false)

References f_menu.

bool TagButton::SetState | ( | const State & | state | ) |

This function adds a state to a button object.

Multiple states with the same flags can be added to the same button. In that case, they all become active at the time the states are satisfied.

Bug:
  If you create a state and omit to set a valid set of flags (i.e. not zero and only the 4 allowed flags) then this function fails.

Parameters:

  `[in]` | state | The state to add to this button object

Returns:
  true when the state is added

References sswf::ErrorManager::ERROR_CODE_BAD_STATE_FLAGS, f_states, sswf::State::GetFlags(), sswf::MemoryManager::MemAttach(), sswf::TagBase::OnError(), and sswf::Vectors::Set().

Referenced by ParseTag().

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

A button is of type:

SWF_TYPE_DEFINE SWF_TYPE_REFERENCE SWF_TYPE_SCRIPT SWF_TYPE_HAS_ID

Returns:
  A set of SWF_TYPE_... flags

Implements sswf::TagBase.

References SWF_TYPE_DEFINE, SWF_TYPE_HAS_ID, SWF_TYPE_REFERENCE, and SWF_TYPE_SCRIPT.

## Member Data Documentation

Vectors sswf::TagButton::f_actions`[private]`

Referenced by Actions(), ParseTag(), PreSave(), Save(), and SetAction().

Vectors sswf::TagButton::f_events`[private]`

Referenced by AddEvent(), PreSave(), and Save().

bool sswf::TagButton::f_menu`[private]`

Referenced by ParseTag(), PreSave(), Save(), and SetMenu().

bool sswf::TagButton::f_save_button2`[private]`

Referenced by ParseTag(), PreSave(), and Save().

Vectors sswf::TagButton::f_states`[private]`

Referenced by PreSave(), Save(), and SetState().

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

- libsswf.h
- libsswf_tag_button.c++