Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

SWFLIB - a free Flash authoring library

, 18 Jul 2006 CPOL
An article on a free Flash authoring library.
samplemovie.zip
SampleMovie.swf
swflibreference.zip
SWFLIB - Programmers Reference.pdf
swflib_library.zip
swflib.dsp
swflib.dsw
swflib_reference.zip
SWFLIB - Programmers Reference.pdf
swflib_samplemovies.zip
SWF Sample Movies
Sample1.swf
Sample2.swf
Sample3.swf
Sample4.swf
Sample5.swf
swflib_testproject.zip
SWFLIB TestProject.dsp
SWFLIB TestProject.dsw
res
SWFLIB TestProject.ico
Sample1.swf
Sample2.swf
Sample3.swf
Sample4.swf
Sample5.swf
bm128.jpg
SWFLIB TestProject.clw
#if !defined(SWFDEFINITIONS_H)
#define SWFDEFINITIONS_H


#include <windows.h>
#include <io.h>
#include <stdio.h>
#include <math.h>


#define	SWF_FILE_VERSION						0x03			// SWF version
#define SWF_MOVIE_WIDHT							 200			// Default movie width
#define SWF_MOVIE_HEIGHT						 200			// Default movie height
#define SWF_FILLSTYLETYPE_SOLID					0x00			// Solid fill
#define SWF_FILLSTYLETYPE_LINEARGRADIENT		0x10			// Linear gradient fill
#define SWF_FILLSTYLETYPE_RADIALGRADIENT		0x12			// Radial gradient fill
#define SWF_FILLSTYLETYPE_BITMAP_0				0x40			// Repeating bitmap fill
#define SWF_FILLSTYLETYPE_BITMAP_1				0x41			// Clipped bitmap fill
#define SWF_FILLSTYLETYPE_BITMAP_2				0x42			// Non-smoothed repeating bitmap fill
#define SWF_FILLSTYLETYPE_BITMAP_3				0x43			// Non-smoothed clipped bitmap fill
#define PI								   3.1415926			// PI value
#define SWF_BUTTON_HIT_STATE					0x08			// Button hit-state flag
#define SWF_BUTTON_DOWN_STATE					0x04			// Button down-state flag
#define SWF_BUTTON_OVER_STATE					0x02			// Button over-state flag
#define SWF_BUTTON_UP_STATE						0x01			// Button up-state flag
#define ACTION_IDLE_TO_OVER_DOWN				0x80			// CondIdleToOverDown flag
#define ACTION_OUT_DOWN_TO_IDLE					0x40			// CondOutDownToIdle flag
#define ACTION_OUT_DOWN_TO_OVER_DOWN			0x20			// CondOutDownToOverDown flag
#define ACTION_OVER_DOWN_TO_OUT_DOWN			0x10			// CondOverDownToOutDown flag
#define ACTION_OVER_DOWN_TO_OVER_UP				0x08			// CondOverDownToOverUp flag
#define ACTION_OVER_UP_TO_OVER_DOWN				0x04			// CondOverUpToOverDown flag
#define ACTION_OVER_UP_TO_IDLE					0x02			// CondOverUpToIdle flag
#define ACTION_IDLE_TO_OVER_UP					0x01			// CondIdleToOverUp flag
#define ACTION_OVER_DOWN_TO_IDLE				0x01			// CondOverDownToIdle flag
#define SWF_OBJECT_TYPE_SHAPE					0x00			// Shape object
#define SWF_OBJECT_TYPE_MORPH_SHAPE				0x01			// Morphing shape object
#define SWF_OBJECT_TYPE_BITMAP					0x02			// Bitmap object
#define SWF_OBJECT_TYPE_BUTTON					0x03			// Button object
#define SWF_OBJECT_TYPE_SPRITE					0x04			// Sprite object


#pragma pack (1)
typedef struct _RECT_F
{
	float left;
	float top;
	float right;
	float bottom;

} RECT_F;

typedef struct _POINT_F
{
	float x;
	float y;

} POINT_F;

typedef struct _SIZE_F
{
	float cx;
	float cy;

} SIZE_F;

typedef struct _SWF_RECT
{
	BYTE Nbits;
	SHORT Xmin;
	SHORT Xmax;
	SHORT Ymin;
	SHORT Ymax;

} SWF_RECT;

typedef struct _MATRIX_F
{
	float scaleX;
	float scaleY;
	float rotateSkew0;
	float rotateSkew1;
	float translateX;
	float translateY;

} MATRIX_F;

typedef struct _SWF_MATRIX
{
	UCHAR MatrixFlags;
	UCHAR NScaleBits;
	ULONG ScaleX;
	ULONG ScaleY;
	UCHAR NRotateBits;
	ULONG RotateSkew0;
	ULONG RotateSkew1;
	UCHAR NTranslateBits;
	ULONG TranslateX;
	ULONG TranslateY;

} SWF_MATRIX;

typedef struct _SWF_FILE_HEADER
{
	UCHAR Signature[3];
	UCHAR Version;
	ULONG FileLength;
	USHORT FrameRate;
	USHORT FrameCount;

} SWF_FILE_HEADER;

typedef struct _SWF_RECORDHEADER_SHORT
{
	USHORT TagCodeAndLength;

} SWF_RECORDHEADER_SHORT;

typedef struct _SWF_RECORDHEADER_LONG
{
	USHORT TagCodeAndLength;
	ULONG Length;

} SWF_RECORDHEADER_LONG;

typedef struct _SWF_RGB
{
	UCHAR Red;
	UCHAR Green;
	UCHAR Blue;

} SWF_RGB;

typedef struct _SWF_RGBA
{
	UCHAR Red;
	UCHAR Green;
	UCHAR Blue;
	UCHAR Alpha;

} SWF_RGBA;

typedef struct _SWF_BGCOLOR
{
	SWF_RECORDHEADER_SHORT Header;
	SWF_RGB BackgroundColor;

} SWF_BGCOLOR;

typedef struct _SWF_GRADIENTRECORD
{
	UCHAR Ratio;
	SWF_RGBA Color;

} SWF_GRADIENTRECORD;

typedef struct _SWF_GRADIENT
{
	UCHAR NumGradients;
	SWF_GRADIENTRECORD* GradientRecords;

} SWF_GRADIENT;

typedef struct _SWF_FILLSTYLE
{
	UCHAR FillStyleType;
	SWF_RGBA Color;
	MATRIX_F GradientMatrix;
	SWF_GRADIENT Gradient;
	USHORT BitmapID;
	MATRIX_F BitmapMatrix;

} SWF_FILLSTYLE;

typedef struct _SWF_FILLSTYLEARRAY
{
	UCHAR FillStyleCount;
	USHORT FillStyleCountExtended;
	SWF_FILLSTYLE* FillStyles;

} SWF_FILLSTYLEARRAY;

typedef struct _SWF_LINESTYLE
{
	USHORT Width;
	SWF_RGBA Color;

} SWF_LINESTYLE;

typedef struct _SWF_LINESTYLEARRAY
{
	UCHAR LineStyleCount;
	USHORT LineStyleCountExtended;
	SWF_LINESTYLE* LineStyles;

} SWF_LINESTYLEARRAY;

typedef struct _SWF_MORPHGRADIENTRECORD
{
	UCHAR StartRatio;
	SWF_RGBA StartColor;
	UCHAR EndRatio;
	SWF_RGBA EndColor;

} SWF_MORPHGRADIENTRECORD;

typedef struct _SWF_MORPHGRADIENT
{
	UCHAR NumGradients;
	SWF_MORPHGRADIENTRECORD* GradientRecords;

} SWF_MORPHGRADIENT;

typedef struct _SWF_MORPHFILLSTYLE
{
	UCHAR FillStyleType;
	SWF_RGBA StartColor;
	SWF_RGBA EndColor;
	MATRIX_F StartGradientMatrix;
	MATRIX_F EndGradientMatrix;
	SWF_MORPHGRADIENT Gradient;
	USHORT BitmapID;
	MATRIX_F StartBitmapMatrix;
	MATRIX_F EndBitmapMatrix;

} SWF_MORPHFILLSTYLE;

typedef struct _SWF_MORPHFILLSTYLEARRAY
{
	UCHAR FillStyleCount;
	USHORT FillStyleCountExtended;
	SWF_MORPHFILLSTYLE* FillStyles;

} SWF_MORPHFILLSTYLEARRAY;

typedef struct _SWF_MORPHLINESTYLE
{
	USHORT StartWidth;
	USHORT EndWidth;
	SWF_RGBA StartColor;
	SWF_RGBA EndColor;

} SWF_MORPHLINESTYLE;

typedef struct _SWF_MORPHLINESTYLEARRAY
{
	UCHAR LineStyleCount;
	USHORT LineStyleCountExtended;
	SWF_MORPHLINESTYLE* LineStyles;

} SWF_MORPHLINESTYLEARRAY;

typedef union _SWF_SHAPERECORD
{
	struct _SWF_ENDSHAPERECORD
	{
		UCHAR ShapeFlags;

	} SWF_ENDSHAPERECORD;

	struct _SWF_STYLECHANGERECORD
	{
		UCHAR ShapeFlags;
		UCHAR MoveBits;
		LONG MoveDeltaX;
		LONG MoveDeltaY;
		USHORT FillStyle0;
		USHORT FillStyle1;
		USHORT LineStyle;
		SWF_FILLSTYLEARRAY NewFillStyles;
		SWF_LINESTYLEARRAY NewLineStyles;
		UCHAR NumberOfNewFillAndLineIndexBits;

	} SWF_STYLECHANGERECORD;

	struct _SWF_STRAIGHTEDGERECORD
	{
		UCHAR ShapeFlags;
		UCHAR NumBits;
		LONG DeltaX;
		LONG DeltaY;

	} SWF_STRAIGHTEDGERECORD;

	struct _SWF_CURVEDEDGERECORD
	{
		UCHAR ShapeFlags;
		UCHAR NumBits;
		LONG ControlDeltaX;
		LONG ControlDeltaY;
		LONG AnchorDeltaX;
		LONG AnchorDeltaY;

	} SWF_CURVEDEDGERECORD;

} SWF_SHAPERECORD;

typedef struct _SWF_SHAPE
{
	UCHAR NumberOfFillAndLineIndexBits;
	SWF_SHAPERECORD* ShapeRecords;

} SWF_SHAPE;

typedef struct _SWF_SHAPEWITHSTYLE
{
	SWF_FILLSTYLEARRAY FillStyles;
	SWF_LINESTYLEARRAY LineStyles;
	UCHAR NumberOfFillAndLineIndexBits;
	SWF_SHAPERECORD* ShapeRecords;

} SWF_SHAPEWITHSTYLE;

typedef struct _SWF_DEFINE_SHAPE_TAG
{
	SWF_RECORDHEADER_LONG Header;
	USHORT ShapeID;
	SWF_SHAPEWITHSTYLE Shapes;

} SWF_DEFINE_SHAPE_TAG;

typedef struct _SWF_DEFINE_MORPHSHAPE_TAG
{
	SWF_RECORDHEADER_LONG Header;
	USHORT CharacterID;
	RECT_F StartBounds;
	RECT_F EndBounds;
	ULONG Offset;
	SWF_MORPHFILLSTYLEARRAY MorphFillStyles;
	SWF_MORPHLINESTYLEARRAY MorphLineStyles;
	SWF_SHAPE StartEdges;
	SWF_SHAPE EndEdges;

} SWF_DEFINE_MORPHSHAPE_TAG;

typedef struct _SWF_PLACE_OBJECT_TAG
{
	SWF_RECORDHEADER_LONG Header;
	UCHAR Flags;
	USHORT Depth;
	USHORT CharacterID;

} SWF_PLACE_OBJECT_TAG;

typedef struct _SWF_REMOVE_OBJECT2_TAG
{
	SWF_RECORDHEADER_LONG Header;
	USHORT Depth;

} SWF_REMOVE_OBJECT2_TAG;

typedef struct _SWF_DEFINE_BITS_JPEG2_TAG
{
	SWF_RECORDHEADER_LONG Header;
	USHORT CharacterID;

} SWF_DEFINE_BITS_JPEG2_TAG;

typedef struct _SWF_CXFORM_WITH_ALPHA_TAG
{
	UCHAR Flags;
	USHORT RedMultTerm;
	USHORT GreenMultTerm;
	USHORT BlueMultTerm;
	USHORT AlphaMultTerm;
	USHORT RedAddTerm;
	USHORT GreenAddTerm;
	USHORT BlueAddTerm;
	USHORT AlphaAddTerm;

} SWF_CXFORM_WITH_ALPHA_TAG;

typedef struct _SWF_COLOR_TRANSFORM
{
	float RedMultTerm;
	float GreenMultTerm;
	float BlueMultTerm;
	float AlphaMultTerm;
	float RedAddTerm;
	float GreenAddTerm;
	float BlueAddTerm;
	float AlphaAddTerm;

} SWF_COLOR_TRANSFORM;

typedef struct _SWF_ACTIONRECORD
{
	UCHAR ActionCode;
	USHORT Length;

	union _ACTION_TYPE
	{
		struct _ACTION_GOTO_FRAME
		{
			USHORT FrameIndex;

		} ACTION_GOTO_FRAME;

		struct _ACTION_GET_URL
		{
			UCHAR* UrlString;
			UCHAR* TargetString;

		} ACTION_GET_URL;

		struct _ACTION_WAIT_FOR_FRAME
		{
			USHORT Frame;
			UCHAR SkipCount;

		} ACTION_WAIT_FOR_FRAME;

		struct _ACTION_SET_TARGET
		{
			UCHAR* TargetName;

		} ACTION_SET_TARGET;

		struct _ACTION_GOTO_LABEL
		{
			UCHAR* Label;

		} ACTION_GOTO_LABEL;

	} ACTION_TYPE;

} SWF_ACTIONRECORD;

typedef struct _SWF_DOACTION_TAG
{
	SWF_RECORDHEADER_LONG Header;
	UCHAR ActionEndFlag;

} SWF_DOACTION_TAG;

typedef struct _SWF_BUTTONCONDACTION_TAG
{
	USHORT CondActionSize;
	UCHAR Flags1;
	UCHAR Flags2;
	UCHAR* Actions;
	int ActionsLength;

} SWF_BUTTONCONDACTION_TAG;

typedef struct _SWF_BUTTONRECORD
{
	UCHAR Flags;
	USHORT CharacterID;
	USHORT PlaceDepth;
	MATRIX_F PlaceMatrix;
	SWF_COLOR_TRANSFORM ColorTransform;
	bool bHasColorTransform;

} SWF_BUTTONRECORD;

typedef struct _SWF_DEFINE_BUTTON2_TAG
{
	SWF_RECORDHEADER_LONG Header;
	USHORT ButtonID;
	UCHAR Flags;
	USHORT ActionOffset;
	SWF_BUTTONRECORD* Characters;
	UCHAR CharacterEndFlag;

} SWF_DEFINE_BUTTON2_TAG;

typedef struct _SWF_DEFINE_SPRITE_TAG
{
	SWF_RECORDHEADER_LONG Header;
	USHORT SpriteID;
	USHORT FrameCount;

} SWF_DEFINE_SPRITE_TAG;
#pragma pack()


#endif // !defined(SWFDEFINITIONS_H)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

darkoman
Software Developer (Senior) Elektromehanika d.o.o. Nis
Serbia Serbia
He has a master degree in Computer Science at Faculty of Electronics in Nis (Serbia), and works as a C++/C# application developer for Windows platforms since 2001. He likes traveling, reading and meeting new people and cultures.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150128.1 | Last Updated 18 Jul 2006
Article Copyright 2006 by darkoman
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid