Linh
Linh

Reputation: 1022

How to read the width and the height of a flash file in C# or JS?

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.

Upvotes: 0

Views: 102

Answers (3)

George E. Litinas
George E. Litinas

Reputation: 31

I think that you can use this one

Upvotes: 1

Mic
Mic

Reputation: 25164

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">
</div>
<script>
    var div = document.getElementById('container'),
        css = window.getComputedStyle(div, null);
    alert( css.height +' - '+ css.width );
</script>

Upvotes: 0

Akash Kava
Akash Kava

Reputation: 39916

You can try "SwfDotNet"

Upvotes: 0

Related Questions