Category Archives: Flash

Compressing A SWF With Java

The title pretty much says it all–this code sample illustrates how to compress a swf file using the Java Deflater class to perform the zlib compression on all the bytes of the swf except for the first 8 bytes which are always uncompressed. This class isn’t intelligent in the sense that it doesn’t check to see if you actually have a valid swf file signature, or check to see that the file is actually uncompressed. So basically you have swf compression in its rawest form.

SWFCompressor.java

Lightweight SWF Header Reader (Java)

One of the cool things about working for TechSmith is I’ve become interested in some of the *lower* level aspects of the Flash platform—namely the swf file format spec. So with the customary confidence of a programmer with a Political Science degree I set off to see if I could parse the swf header to extract the following information:

  • file signature
  • version
  • size
  • width
  • height
  • frame rate
  • frame count

After much gnashing of teeth and a quick lesson in bit shifting from Tom Sirgedas, a C++ dev on the Camtasia Studio team, I developed a utility that parses uncompressed swf files. The big caveat is that it only parses uncompressed swf files—being a java rookie, I’m still working on how to “inflate” a compressed swf file.

However, rather than just sitting on this until I find the time and inclination to inflate compressed swf’s I’m going to release this utility / code to the community under the MIT license. If you are a swf file format or java master and want to post back thoughts or ideas I’d certainly appreciate it.

Jar file usage: java -jar swfheader.jar [swf file]

Download swf header parser jar file.

Download java source (code was condensed into a single file for web download).

I’m not sure how useful this is, but it could have some application in server-side code. For instance, perhaps you allow users to upload swf files to a CMS system. When a request to play back the file comes, the server can quickly parse the header for the width and height to be used when generating the embed tags.

The real value here is that of a lightweight example of parsing the header in Java. Reading the file format specification isn’t a whole lot of fun if you’re coming at it from the non-computer science background that many of us in the Flash community have. If you’re interested in a full blown framework for reading and writing swf files with Java checkout Flagstone’s Transform SWF library (and source code).

Setting Mac / Unix Environment Variables – Adding Executables to the System Path

After years of resistance I finally caved and bought a sleek, shiny MacBook Pro over the weekend. I’ve been slowly figuring out how to set up my AMES development environment and that means figuring out the basics of using the Unix shell. I struggled to find a simple explanation of how to set environment variables, so I’m inserting a couple of screen grabs which illustrate how to add MTASC and Swfmill to the PATH environment variable.

I downloaded, unzipped and placed the mtasc and swfmill binaries in their respective folders in the following folder:
/usr/local/bin
Method 1 : A Session Variable – Using the bash shell, this adds the mtasc and swfmill binaries to the PATH variable for the current terminal session. When you close the shell and reopen it, you’ll have to add the files to the PATH variable again.

There’s actually a typo in the screen grab–it should be:

export PATH=$PATH:/usr/local/bin/mtasc:/usr/local/bin/swfmill

Method 2: Add to Startup Script – Place the command in a startup script called bashrc which can be found along the path below. The modified PATH will always be available to any bash shell and no further editing is needed.
/etc

This method is similar to how environment variables are set in Windows (without the gui absraction layer). the bashrc file is a simple text file and you simply add the commands to this script which is run everytime the os loads.

I can now reference mtasc or swfmill in the bash sell by simply typing the executable name!Since, I opted for the “set it and forget it” method, I know I at least will benefit from having something to reference the next time I have to set up OSX or Linux (I vaguely remember doing this when I first forayed into Linux a year ago and cursed my laziness at not writing down the process)….maybe there are others out there who have shared the pain of leaving their comfortable Windows double-wide trailer and gone hollywood with the glamorous mac-villa “Made by Apple in California” :)

FITC 2006 Presentation Screencasts

I created 48 minutes worth of tutorials exploring the use of Camtasia Studio, Flash, After Effects and more for my FITC presentation (way more than anyone will be able to stomach, but it was worth not sleeping for a 4 days :) ).

I haven’t updated the rss feed for the podcasts, but will tomorrow so that you can see what they look like in that format. I’m going to try and scratch out a couple of hours of sleep before my 9:00 A.M. presentation tomorrow.

Update: I have updated my itunes podcast feed, so you can now download and watch the screencasts on your video ipod.

subscribe with itunes

Create a table of contents navigation tree for Camtasia Studio output
screencast thumbnail

Customize your Camtasia Studio table of contents
screencast thumbnail


Use After Effects to apply perspective and animation to Camtasia Studio screen recordings

screencast thumbnail


Hack Camtasia Studio to Create a Flash 8 swf that imports into the Flash IDE without artifacting

screencast thumbnail

Camtasia Studio makes major improvements to html wrapper—SwfObject (formerly known as FlashObject), CSS, XHTML 1.0 strict
screencast thumbnail


Embed your Flash screencasts into your WordPress blog

screencast thumbnail