Reading parameters of a SWF file using ASP!
October 31, 2001
Ever wanted to read the properties of a SWF file such as height and width? Well, I did. Openswf.org was a good starting point for me. They have a SWF parser written in C++ that can grab all the information you need. There are also a number of server-side objects that can do the trick as well. However, I needed a solution that would work without any custom server-side objects. So, I went on my merry way to try and convert the C++ code into JavaScript or VBScript. In the end, I created something that was a combination of both.
If you check out the code, you'll notice that it's broken down into essentially three parts. The first part is some JavaScript functions, the second is some VBScript functions and then I have the actual VBScript code that calls all my functions.
The way I use this is as follows:
dim astfilename astfilename = "c:\myflashfile.swf" <!--#include file="swfparser.asp" -->
After I've done this, I will have access to the following variables:
- strFilepath : which should be the same as astfilename
- isFlash : a boolean variable
- intVersion : what version of Flash
- swfwidth : the width of the Flash
- swfheight : the height of the Flash
This code can also be expanded to grab some addiitional information such as frame rate. Head back to openswf.org to get all the specs on the SWF file format.
Update:
Some time after I created this article I came across another site who created
a VBScript class to accomplish the same task. Check out this user
tip on 4guysfromrolla.com.