SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Guru JoePrice's Avatar
    Join Date
    Jan 2002
    Location
    UK
    Posts
    673
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    loading a javascript variable into a flash movie embed code in html

    Hi Chaps

    Hold tight, here's my problem and i'd welcome any suggestions!

    I'm determining the screen resolution of users in javascript. Depending upon what resolution they have, the dimensions of the resulting flash movie I want them to view will be different.

    I have 2 javascript variables flashWidth and flashHeight. I need them to be embedded into the html file where it specifies the flash movie properties:

    Code:
     WIDTH="flashWidth Variable" HEIGHT="flashHeight Variable"
    How do I put these two variables into the flash html code? do i put the entire flash html code within a document.write() command? even if so, how do i then place the flashWidth & flashHeight variables into that code since i'm already within the <embed> tag defining the flash movie. Nesting a <script> tag within that I dont think will work?

    Any suggestions would be most welcome.

    Cheers

  2. #2
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gooday,

    Your on the right track. Just docwrite the whole tag wherever you want in your html. Whenever I put flash in any pages, I always write out all the flash tags with javascript anyway since that is the only way for my xhtml to validate in strict mode.

    Code:
    <script type="text/javascript">
    //<![CDATA[
    	var fStr = "";
    	fStr += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    	+ ' codebase="http://download.macromedia.com/pub/shockwave/cabs/'
    	+ 'flash/swflash.cab#version=6,0,0,0"'
    	+ 'width="'+flashWidth+'" height="'+flashHeight+'" id="pept" align="">'
    	+ '<param name=movie value="pept.swf"> '
    	+ '<param name="WMode" value="Transparent">'
    	+ '<param name="quality" value="high">'
    	+ '<param name="bgcolor" value="#ffffff">'
    	+ '<embed src="pept.swf" quality="high" bgcolor="#ffffff" '
    	+ ' width="'+flashWidth+'" height="'+flashHeight+'" name="pept" align="" '
    	+ 'type="application/x-shockwave-flash" '
    	+ 'pluginspace="http://www.macromedia.com/go/getflashplayer">'
    	+ '</embed></object>';
    document.write(fStr);
    //]]>
    
    </script>
    -xDev


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •