PDA

View Full Version : TGetPropertyAsNumber


alexandre_lab
12-06-2003, 08:05 PM
Hello !

I'm trying to use javascript to retrieve some properties of a swf file (the width and height) and use them to affect the "embed" code.
The reason i do this (and not hardcode the width and height) is that users can upload their flash file on my website's database. I don't want to rely on them telling me the width and height, but would prefer to get the real value out of the file.

i found a technote that seems to enable me to do it:
http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_04.html

but i can't make it work so far :(

Here is my code, can someone tell me what i'm doing wrong ?


<script type="text/javascript" language="javascript">
<!--
var finalwidth=window.document.navmovie.TGetProperty("/",8);
var finalheight=window.document.navmovie.TGetProperty("/",9);

</script>

the embed code is:

<script>
document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
document.writeln('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ID="navmovie" width="'+ finalwidth + '" height="' + finalheight + '" hspace="0" vspace="0" align="middle">');
document.writeln('<PARAM NAME=movie VALUE="filez/' + file + '"><PARAM menu=false quality=high>');


document.writeln('<EMBED name="navmovie" src="filez/' + file + '" menu=false quality=high bgcolor=#000000 swLiveConnect="true" width="' + finalwidth + '" height="' + finalheight + '" TYPE="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>');
</script>


Thanks a lot for your help !


alex

mrand01
12-08-2003, 01:37 PM
as far as I know this can't be done. I've been writing apps in VB using the flash activeX control, and TGetPropertyAsNumber never returns the correct width and height. It returns the used width and height of the stage. For instance, if your .swf is 400X400, but you only use 246X134 of that space, TGetPropertyAsNumber returns 246X134, not 400X400. VERY VERY ANNOYING. The only way to get the true width and height, as far as I know (and I've researched this for months), is to parse binary data out of the SWF header to get these values. The binary data you need to parse can be found in the SWF File Format SDK. Good luck.

Navin
09-09-2006, 12:16 PM
You may want to use this app for detecting Flash movie's width & height:

http://navin.biz/files/SWFParser.zip

It's a free tool written in C# (.NET Framework 2.0) and contains all source code.

http://navin.biz/files/SWFParser.png

alexandre_lab
09-09-2006, 12:48 PM
hi navin,

thanks for the tip. The thing is, i need to have this run on my webspace, so integrate it in a way or another to php. I was hoping a built in solution would exist inside of flash.