Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Reading Flash (Swf) metadata from ColdFusion

Wouldn't it be cool if you could read the meta-data of Swf file in ColdFusion? The most common use case I can think of is to find the Dimension of swf movie so that you can set the dimension for the same in object tag while you are embedding the Flash movie in your page. And the good news is that you can do that currently in Coldfusion with just 2-3 lines of code!! All you need to do is to create a TagDecoder and decoder the header with it. Here is the complete code.


fis = createObject("java", "java.io.FileInputStream").init("C:\test.swf"); // Create the FileInputStream
decoder = createObject("java", "macromedia.swf.TagDecoder").init(fis); // create TagDecoder
header = decoder.decodeHeader(); // Decode the header.
fis.close();
rect = header.size;
WriteOutput("
Is Compressed : #header.compressed#<br>
Frame Count : #header.framecount#<br>
Frame rate : #header.rate#<br>
Version : #header.version#<br>
Height : #rect.getHeight()#<br>
Width : #rect.getWidth()#");
</cfscript>

The height and width value that you see here would be in twips which is defined as 1/20 of a point or 1/1440 inch. This means, for a 72 dpi screeen, you will have to divide it by 20 to get the height and width in pixels.



This post first appeared on Coldfused?, please read the originial post: here

Share the post

Reading Flash (Swf) metadata from ColdFusion

×

Subscribe to Coldfused?

Get updates delivered right to your inbox!

Thank you for your subscription

×