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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing object

Status
Not open for further replies.

RedRobotHero

Technical User
May 2, 2003
94
CN
So I am trying to make a script that resizes a flash object according to what the screen can fit. I don't do a lot of Javascript, so I could be making an obvious mistake.

Here is the source.

Code:
<OBJECT id=&quot;flashobj&quot; WIDTH=400 HEIGHT=400>
<PARAM NAME=movie VALUE=&quot;flashfil.swf&quot;> 
<EMBED id=&quot;flashembed&quot; src=&quot;/images/pandora.swf&quot; WIDTH=400 HEIGHT=400 TYPE=&quot;application/x-shockwave-flash&quot;></EMBED>
</OBJECT>

<script language=JavaScript>
var flashwidth = (window.screen.availHeight*0.8);
obj = document.getElementById('flashobj');
obj.WIDTH = flashwidth;
obj.HEIGHT = flashwidth;
emb = document.getElementById('flashembed');
emb.WIDTH = flashwidth;
emb.HEIGHT = flashwidth;
</script>


Now, when I load the page, it gives me an error, saying that
Code:
'emb' is null
. But it gives me no error for 'obj'. So I guess EMBED can't have an ID?

Is there a better approach that I should take instead?
 
eh, i would guess that <embed> is not an actual object like <object> is but more like a parameter...do you have any problems dynamically changing the <object> height and width?



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
The OBJECT width works fine.

(As a side note, I had to change HEIGHT and WIDTH to lowercase height and width, but I still can't access EMBED.)
 
I have this example from a Wrox book about installing ActiveX control for Flash...

<HTML>
<HEAD>
<OBJECT CLASSID=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-44553540000&quot;
CODEBASE=&quot; //no semicolon at the end
ID=flashPlayer1
WIDTH=500
HEIGHT=100 >
<PARAM NAME=SRC VALUE=&quot;myFlashMovie.swf&quot;>
<PARAM NAME=QUALITY VALUE=high>
</OBJECT>
</HEAD>
<BODY>
<NOEMBED>
<H2>This Page requires a browser supporting Plug-ins or ActiveX controls</H2>
</NOEMBED>
</BODY>
</HTLM>

//CODEBASE will direct to the URL to install the component if not already installed on the users local machine
//You may be able to download the .cab file that installs the control on your server (subject to license agreements) and point the CODEBASE attribute to that.
//CODEBASE and CLASSID can both be found on your local machine if you have the component installed and then accessing the properties window of the component where it is located on your local machine

Here is an example of Real Player

<HTML>
<HEAD>
<OBJECT CLASID=&quot;clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA&quot; ID =&quot;real1&quot;>
<PARAM NAME=&quot;HEIGHT&quot; VALUE=&quot;0&quot;>
<PARAM NAME=WIDTH&quot; VALUE=&quot;0&quot;>
<EMBED
NAME=&quot;real1&quot;
ID=&quot;real1&quot;
BORDER=&quot;0&quot;
CONTROLS=&quot;play&quot;
HEIGHT=0
WIDTH=0
TYPE=&quot;audio/x-pn-realaudio-plugin&quot;>
</OBJECT>
</HEAD>

<BODY>
<NOEMBED>
<H2>This page requires a browser supporting Plug-ins or ActiveX controls</H2>
</NOEMBED>
</BODY>
</HTML>

Tweek your code based from the above two examples and see what you come up with. Notice that when using the <EMBED> tag that there is NO ending tag </EMBED>

Hope this helps you out,

Brian
 
sdi: I had cut some of those things (CLASSID, CODEBASE) out when I posted my example source because I assumed they wouldn't have anything to do with accessing things with ID or changing the WIDTH and HEIGHT. The HTML code I use is based on that produced by Flash 5's 'publish' command.

It is interesting that your example of the Flash object doesn't even have an EMBED, which is what has been giving me trouble. IIRC, changing the OBJECT width and height was enough for some browsers. Maybe I can just try to get by without the EMBED entirely.
 
I've sidestepped the whole thing by using an <IFRAME> instead of <OBJECT> and <EMBED>. So far, that's the best solution I've found, which works consistently in IE, Netscape, and Opera.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top