# resizing an embedded flash object according to monitor resolution - with javascript?



## Sphinx (Aug 5, 2003)

Hey guys,

Here's my issue - and hopefully I can get this fixed by the end of today because it's the last day of my job (going back to school). We have a web portal for our IT group here at the company, and I have a flash file embedded, which will look fine on a 1024x768 monitor, but will be too small on higher resolutions.

Is there a way I can grab the resolution of the screen using javascript, into variables "x" and "y" (for example), and use those to calculate the correct pixel width and height of the flash object, and then set it to that width and height. ?

Here is my code for the flash object embedding:

main.swf

My current dimensions of the object at 575 x 355 I would like to be changed if the user has a different resolution (while of course maintaining the same aspect ratio).

Appreciate the help I get here as always,

Sphinx


----------



## Sphinx (Aug 5, 2003)

I tried putting document.write around all the HTML tags, and have the whole object embedding section within a <script> , and then referencing "x" and "y" which were javascript variables that contain screen.width and screen.height respectively, however the flash object fails to load when I try this.


----------



## namenotfound (Apr 30, 2005)

If you link directly to the flash object, and not embed it, it will expand to the width and height of the users' screen.


----------



## Sphinx (Aug 5, 2003)

It can't be a link though, it must appear on the home page.


----------



## MMJ (Oct 15, 2006)

Please use [code] or [html] tags when posting code.

You can check [element.]offetHeight / [element.]offetWidth.


----------

