Reading parameters of a Macromedia Flash (SWF) file using ASP
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.
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.
Conversation
Just a quick note that this only works on Flash files up to version 5. In Flash 6, they implemented compression using the zlib format. If somebody comes up with a vbscript or javascript approach to decompress it, it should be easy enough to grab these parameters then.
hi all...
can u plz send a clear idea about how to find out the heigh and width parameters of uploaded files...
Thanks...
one line of code includes
if ucase(strTag) = "FWS" then isFlash=true
Well, a compressed flash file is "CWS", and you need gzip compression to uncompress everything from the 8th byte and on. Can you help us out with that?
I never got around to developing an ASP gzip decompressor. Creating one isn't something I'm interested in as ASP is certainly not as popular as it once was. Good luck with your project.
Hi,
I have checked the swf information reading code...Its not working for flash version 7...
PLease advice me.
Thanx & Rgds,
Prakash
I will use this code for flash games page on my sport web page.
Thank you very much.