Determining native size of a SWF (and code to embed it in SharePoint)

Currently working on a Sharepoint reference site that collates a number of Captivate demonstrations. To make the site look presentable it’s necessary to preset the size of each Captivate demo. But how do you know what the native size is so you can determine the appropriate aspect ratio?

Here’s my way.

(1) Download SWFTools

This is a collection of useful little programs for creating and manipulating SWFs. For our purposes the one we want to use is SWFDUMP (read the doco here)

Download Link.

These executables are (on Windows) installed by default in a folder under C:Program Files. To be able to use open a CMD window and navigate to the new folder.

(2) Run SWFDUMP

Once downloaded run the following command to get the required default info.

SWFDUMP -e "path to your SWF"

Easiest way to do the above is type the first part of the command in a CMD window, and when you get to enter the SWF details just drag your SWF file into the window. It will automatically determine the full pathname and add it to your command.

What this generates is the standard HTML embed code, which includes the all important sizes. For example here’s the output when run on my Windows XP work machine.

<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 WIDTH="1153"
 HEIGHT="895"
 CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version=10,0,0,0">
  <PARAM NAME="MOVIE" VALUE="pathtoCreateProposal.swf">
  <PARAM NAME="PLAY" VALUE="true">
  <PARAM NAME="LOOP" VALUE="true">
  <PARAM NAME="QUALITY" VALUE="high">
  <PARAM NAME="ALLOWSCRIPTACCESS" VALUE="always">
<EMBED SRC="pathtoCreateProposal.swf" WIDTH="1153" HEIGHT="895"
   PLAY="true" ALIGN="" LOOP="true" QUALITY="high"
   TYPE="application/x-shockwave-flash"
   ALLOWSCRIPTACCESS="always"
   PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
  </EMBED>
</OBJECT>

Note: You can cut to the chase and retrieve just the size info with the following commands.

SWFDUMP -X "path to your SWF"
SWFDUMP -Y "path to your SWF"

But that’s more typing.

A more useful suggestion if wanting to use this HTML code, save it to a text file to make it easier to cut&paste:

SWFDUMP -e "path to your SWF" > code.txt

(3) Adjust the native sizes to fit the required space

For me all the demonstrations need to be presented at a fixed 650px width. So I need to calculate the required height that keeps the same aspect ratio as the native SWF but at 650px wide.

Simple bit of maths to determine:

RequiredX = 650
RequiredY = CurrentY * (RequiredX/CurrentX)

So for the above example:

RequiredX = 650
RequiredY = 895 * (650/1153) = 505 (with a bit of rounding)

Sorted.

One thought on “Determining native size of a SWF (and code to embed it in SharePoint)

  1. steven Post author

    Actually there is an even easier way to just get the sizes.

    swfdump -XY "filename"
    

    Essentially you can combine the two calls for width and height into one command. Then you get both answers back in one line:

    -X 1025 -Y 769
    
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>