Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onresize pereserve aspect ratio of embeded flash

Status
Not open for further replies.

chopficaro

Programmer
May 10, 2008
11
US
this doesnt seem to be working. im trying to determine the width of a flash object based on the height of the window onresize
Code:
window.onresize = function()
{
document.getelementById("containerA").style.width=windowheight/2;
}
 
Hi

And the numeric value resulted from the windowheight/2 formula should be interpreted as [tt]em[/tt], [tt]ex[/tt], [tt]px[/tt], [tt]gd[/tt], [tt]rem[/tt], [tt]vw[/tt], [tt]vh[/tt], [tt]vm[/tt], [tt]ch[/tt], [tt]in[/tt], [tt]cm[/tt], [tt]mm[/tt], [tt]pt[/tt], [tt]pc[/tt] or [tt]%[/tt] ?

Probably you want this :
Code:
window[teal].[/teal]onresize [teal]=[/teal] [b]function[/b][teal]()[/teal]
[teal]{[/teal]
document[teal].[/teal][COLOR=darkgoldenrod]getelementById[/color][teal]([/teal][green][i]"containerA"[/i][/green][teal]).[/teal]style[teal].[/teal]width[teal]=[/teal]windowheight[teal]/[/teal][purple]2[/purple][highlight][teal]+[/teal][green][i]'px'[/i][/green][/highlight][teal];[/teal]
[teal]}[/teal]

Feherke.
 
thats still not quite working, heres my html if it helps:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<html xmlns=" lang="en" xml:lang="en">
<head>
<title>SWFObject - step 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="screen">
html, body, #containerA { width:100%; height:100%; }
body { margin:0; padding:0; overflow:hidden;}
</style>

<style type="text/javascript" src="resize.js"></style>



</head>
<body>
<div id="containerA">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%">
<param name="movie" value="yankeeScreenMenu.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="yankeeScreenMenu.swf" width="100%" height="100%">
<param name="quality" value="autohigh" />
<param name="menu" value="false" />
<!--<![endif]-->
<p>Alternative content</p>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>
 
Hi

Well, as far as I know, it is not.

The closest would be [tt]window.outerHeight[/tt]. Which according to Peter-Paul Koch's article, W3C DOM Compatibility - CSS Object Model View, works in Gecko, Presto, WebKit and KHTML and, of course, not works in Trident.

I have no idea what you could do in Explorer. A quick look at the window Object in MSDN shows nothing suitable to find out the height.

Feherke.
 
isnt (sic) it a keyword or something?

I would have thought you would have been able to use Google to ascertain that before posting meaningless code to a professional site asking for help.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info:
The Out Atheism Campaign
 
well i tried this first
Code:
window.onresize = function()
{
document.getelementById("containerA").style.width=document.getelementById("containerA").style.height/20+'px';
}
 
Hi

And where is that getelementById defined ?

And no, neither that is a "keyword or something".

Unless you consider a typo to be something. In which case please note that JavaScript is case sensitive and the DOM method's name is [tt]get[red]E[/red]lementById()[/tt].

By the way, have you explicitly set the [tt]style.height[/tt] property of containerA previously ? If not, reading it will give an empty string. In that case you have to get the property through [tt]getComputedStyle()[/tt], as described in Peter-Paul Koch's article, Get Styles.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top