Click here to Skip to main content
Click here to Skip to main content

SWFLIB - a free Flash authoring library

By , 18 Jul 2006
 

Introduction

This article is about a small SWF authoring library written in C++. It can be used from any desktop application to generate Flash animations at run-time. In this release, the library can generate SWF version 3 movies, without sounds and text. This release has extended SWF tag support to cover buttons, actions, and sprites. Since this is an a experimental project, the future releases will be extended with additional functionality. For now, you are able to generate any kind of animation from the C++ source code and test it in any browser that supports Flash. The goal here is not to chase the latest SWF file format specification, but to enable developers to test this tool in their projects.

Background

Similar SWF authoring tools could be found on the Internet but with different support for generating Flash animations.

Using the code

You can use this library by downloading the SWFLIB project file and recompiling it. The project you use the library in must include the library header files and link to the swflib.lib file. The possible problem would be default project linking to the LIBCD.LIB library in the Project->Settings... and then the Link tab. The solution would be to select Input from the Category combo-box and to write the library name (LIBCD.LIB) in the Ignore section. It has worked for me in the TestProject that can be found in the download section on this page.

Generating a simple Flash movie would look like this:

#include "SWFMovie.h"

SIZE_F movieSize = {400, 400};
int frameRate = 12;
CSWFMovie swfMovie;

// Open new .SWF file
swfMovie.OpenSWFFile("Sample.swf", movieSize, frameRate);

// Define a simple shape
USHORT nID = 1;
USHORT depth = 1;
RECT_F shapeRect = {0, 0, 200, 200};
CSWFShape shape(nID, shapeRect, depth);
int lineWidth = 2;
SWF_RGBA lineColor = {255, 0, 0, 255};
shape.AddLineStyle(lineWidth, lineColor);
SWF_RGBA fillColor = {0, 0, 255, 255};
shape.AddSolidFillStyle(fillColor);
shape.AddLineSegment(100, 0);
shape.AddLineSegment(0, 100);
shape.AddLineSegment(-100, 0);
shape.AddLineSegment(0, -100);
swfMovie.AddShape(&shape, shape.m_Depth, true);
swfMovie.ShowFrame();

// Close .SWF file
swfMovie.CloseSWFFile();

Please understand that it is not possible to describe the whole functionality of the SWFLIB library using a single web page. You can find the SWFLIB Programmers Reference document in the download section, with the complete SWFLIB library specification.

Very important note

This library is just a thin wrapper around SWF tags, so don't expect final solutions. You'll have to build them using your mathematical skills and imagination. The animations are all about mathematical transformations, so you need 2D math tricks in order to get interesting effects. But don't be sad, with some practice, you'll make it for sure.

Points of interest

Working on this project was very exciting, and the future releases will increase the functionality of this library. So far, there are no noticed memory leaks, but if you detect one, please report it.

History

SWFLIB.LIB v1.1, release date - July 4, 2006

  • Buttons
  • SWF 3 Actions
  • Sprites

SWFLIB.LIB v1.0, release date - June 26, 2006

  • Custom shapes
  • Morphing shapes
  • JPEG file support
  • Line and fill style definition
  • Geometrical transformations
  • Color transformations

License

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

About the Author

darkoman
Software Developer (Senior) Elektromehanika d.o.o. Nis
Serbia Serbia
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionCSWFButton HelpmemberMember 88861093 Oct '12 - 13:26 
BugRotation Problem!!!memberSimonCommon24 Dec '11 - 1:22 
GeneralI couldnt add more frame into the swf movie [modified]memberrootlife4 Nov '09 - 19:40 
GeneralRe: I couldnt add more frame into the swf moviememberdarkoman5 Nov '09 - 9:10 
GeneralRe: I couldnt add more frame into the swf moviememberrootlife8 Nov '09 - 1:07 
GeneralError while building test appmembersajidadesh11 Jan '09 - 23:43 
Generalcompiling swflib projectmemberxavier6617 Sep '08 - 2:18 
QuestionHow to transcode flash type to other media typememberMember 30495742 Mar '08 - 21:10 
QuestionText TagmemberStephen Herd11 Oct '07 - 14:13 
AnswerRe: Text Tagmemberdarkoman12 Oct '07 - 2:01 
GeneralRe: Text TagmemberStephen Herd12 Oct '07 - 2:45 
GeneralI see only the first frame.memberShlomo15 Jul '07 - 2:55 
GeneralRe: I see only the first frame.memberdarkoman6 Aug '08 - 4:39 
QuestionHow can I add an action context ?membermillion12320 May '07 - 3:19 
AnswerRe: How can I add an action context ?memberdarkoman20 May '07 - 9:11 
GeneralRe: How can I add an action context ?membermillion12320 May '07 - 17:46 
GeneralRe: How can I add an action context ?memberdarkoman20 May '07 - 19:32 
GeneralRe: How can I add an action context ?membermillion12321 May '07 - 3:25 
GeneralRe: How can I add an action context ?memberdarkoman21 May '07 - 8:28 
GeneralRe: How can I add an action context ?membermillion12321 May '07 - 15:22 
GeneralRe: How can I add an action context ?memberdarkoman21 May '07 - 19:36 
GeneralRe: How can I add an action context ?membermillion12321 May '07 - 20:43 
Questionthanks for the code; do you want credit on my web page?memberDr. Zarkov24 Apr '07 - 7:05 
thanks for this work, I have 2 questions:
1. the PDF doc says support for v4 is forthcoming; any ETA? progress? status?
2. i want to put some flash animations i make, using your SWFlib, on my web page; would you like a credit? if so, what would you like? (e.g., link to this page? your name? etc.)
AnswerRe: thanks for the code; do you want credit on my web page?memberdarkoman24 Apr '07 - 9:44 
GeneralRe: thanks for the code; do you want credit on my web page?memberDr. Zarkov4 May '07 - 7:47 
AnswerRe: thanks for the code; do you want credit on my web page?memberdarkoman5 May '07 - 2:42 
QuestionBitmap animation won't update second framemembersfaul20 Apr '07 - 5:58 
AnswerRe: Bitmap animation won't update second framememberRonaldY6 May '08 - 21:27 
AnswerRe: Bitmap animation won't update second framememberdarkoman6 Aug '08 - 4:33 
QuestionCan Scale(...) work beyond 1.0 (100%) ?membergordon8819 Nov '06 - 14:30 
AnswerRe: Can Scale(...) work beyond 1.0 (100%) ?memberdarkoman19 Nov '06 - 19:49 
GeneralRe: Can Scale(...) work beyond 1.0 (100%) ?membergordon8827 Nov '06 - 12:10 
GeneralI can't add two key frame to the swf moviememberwinart16 Jul '06 - 18:36 
GeneralRe: I can't add two key frame to the swf moviememberdarkoman23 Jul '06 - 22:35 
GeneralType Issuesmemberrssmsvc7 Jul '06 - 16:36 
GeneralWhy reinvent the wheelmemberskycoder4 Jul '06 - 0:53 
GeneralRe: Why reinvent the wheelmemberdarkoman4 Jul '06 - 1:35 
GeneralRe: Why reinvent the wheelmemberskycoder4 Jul '06 - 5:18 
GeneralRe: Why reinvent the wheel-think again...memberHomero De la Garza30 Jul '06 - 18:11 
GeneralRe: Why reinvent the wheel-think again...memberskycoder30 Jul '06 - 20:22 
GeneralMy apologies too...memberHomero De la Garza31 Jul '06 - 8:40 
GeneralRe: My apologies too...memberskycoder31 Jul '06 - 20:40 
GeneralirrlichtmemberHomero De la Garza2 Aug '06 - 15:15 
QuestionCan you explain more how to fill with bitmaps ?memberThierry Maurel1 Jul '06 - 6:58 
AnswerRe: Can you explain more how to fill with bitmaps ?memberdarkoman1 Jul '06 - 13:04 
Generalsome swf file don't playmemberwinne_ll28 Jun '06 - 2:55 
GeneralRe: some swf file don't playmemberdarkoman28 Jun '06 - 3:42 
GeneralRe: some swf file don't playmemberwinne_ll28 Jun '06 - 16:20 
GeneralRe: some swf file don't playmemberdarkoman28 Jun '06 - 22:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 18 Jul 2006
Article Copyright 2006 by darkoman
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid