tags:

views:

16

answers:

2

Hi all,

What will i do to read the width and the height of a flash file (*.swf) in C# or JS?

I tried a solution in CodeProject.com but return value of height is incorrect.

A: 

You can try "SwfDotNet"

Akash Kava
Thank akash! I read the SwfDotNet Documentation but i didn't see a clear solution to resolve my problem.
Linh
A: 

Did you try getComputedStyle?
Here is a cross browser implementation coming from here

function getStyle(el, cssprop){
 if (el.currentStyle) //IE
  return el.currentStyle[cssprop]
 else if (document.defaultView && document.defaultView.getComputedStyle) //others
  return document.defaultView.getComputedStyle(el, "")[cssprop]
 else //try and get inline style
  return el.style[cssprop]
}

getStyle(elm, 'height')

It returns the value of any css property of an element.

If that doesn't work you could try to embed your flash file in a DIV and measure it instead of the swf object.

EDIT:

Here is an example that work on webkit, Opera.

<div id="container" style="float:left">
    <embed 
      type="application/x-shockwave-flash"
      src="http://s.ytimg.com/yt/swf/watch_as3-vfl178359.swf"&gt;
</div>
<script>
    var div = document.getElementById('container'),
        css = window.getComputedStyle(div, null);
    alert( css.height +' - '+ css.width );
</script>
Mic
Thank Mic for your help.I did as follows your advice but no success. On Firefox the value of height is incorrect and On IE is 'auto'.
Linh
strange... look at the example I added. My Firefox doesn't want to start since the last update and I don't have an IE to test right now...
Mic
Hi mic, I think the Javascript solution is impossible because the Macromedia Flash Player work directly with the flash object instead of the Browser Engine.I'm looking the C# solution.
Linh
At least we tried :( Good luck.
Mic