www.pudn.com > C++_Flash.rar > SWFButton.cpp
// SWFButton.cpp: implementation of the CSWFButton class.
//
//////////////////////////////////////////////////////////////////////
#include "SWFButton.h"
CSWFButton::CSWFButton(USHORT nID, USHORT depth, bool bMenuButton)
{
// Init members
m_ObjectType = SWF_OBJECT_TYPE_BUTTON;
memset(&m_Button, 0, sizeof(SWF_DEFINE_BUTTON2_TAG));
m_Button.Header.TagCodeAndLength = (34 << 6) | 0x003F;
m_Button.ButtonID = nID;
if (bMenuButton)
m_Button.Flags = 0x01;
m_Button.ActionOffset = 0;
m_Button.Characters = NULL;
m_NumberButtonRecords = 0;
m_ID = nID;
m_Depth = depth;
m_NumberCondActions = 0;
m_ButtonCondActions = NULL;
m_SWFStream = NULL;
m_SWFStreamLength = 0;
}
CSWFButton::~CSWFButton()
{
if (m_SWFStream != NULL)
{
free(m_SWFStream);
m_SWFStream = NULL;
}
if (m_Button.Characters)
{
free(m_Button.Characters);
m_Button.Characters = NULL;
}
if (m_ButtonCondActions != NULL)
{
for (int i=0; iIsButtonAction())
{
pActionBuffer = pAction->BuildSWFStream();
actionBufferLength = pAction->GetSWFStreamLength();
}
}
// Create new BUTTONCONDACTION entry
SWF_BUTTONCONDACTION_TAG newButtonCondActionRecord;
memset(&newButtonCondActionRecord, 0, sizeof(SWF_BUTTONCONDACTION_TAG));
newButtonCondActionRecord.Flags1 = flags1;
newButtonCondActionRecord.Flags2 = flags2;
if (m_NumberCondActions > 0)
{
newButtonCondActionRecord.CondActionSize = sizeof(USHORT) + actionBufferLength + 2*sizeof(UCHAR);
// Update ButtonCondActionArray
for (int j=0; j