A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: How to center a flash movie in the browser window

  1. #1
    Junior Member
    Join Date
    Jan 2004
    Location
    California
    Posts
    13

    How to center a flash movie in the browser window

    I published a flash file with html from Flash MX but the movie plays in the top left corner of the browser window no matter what I specify in the publish settings. I pasted the html code below and can someone tell me exactly what to add where or change in order to have it play in the center vertically and horizontally.

    Thanks to all that help and read this.




    <HTML>
    <HEAD>
    <meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
    <TITLE>ImagineEye</TITLE>
    </HEAD>
    <BODY bgcolor="#B9B8B0">
    <!-- URL's used in the movie-->
    <!-- text used in the movie-->
    <!--BEST VIEWED AT 1024 x 768 RESOLUTIONALL PHOTOGRAPHS © 2004 MICHAL PFEILImagineEye--><OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
    WIDTH="980" HEIGHT="600" id="ImagineEye" ALIGN="top">
    <PARAM NAME=movie VALUE="ImagineEye.swf"> <PARAM NAME=loop VALUE=false> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=scale VALUE=exactfit> <PARAM NAME=bgcolor VALUE=#B9B8B0> <EMBED src="ImagineEye.swf" loop=false menu=false quality=high scale=exactfit bgcolor=#B9B8B0 WIDTH="980" HEIGHT="600" NAME="ImagineEye" ALIGN="top"
    TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
    </OBJECT>
    </BODY>
    </HTML>

  2. #2
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    <HTML>
    <HEAD>
    <meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
    <TITLE>ImagineEye</TITLE>
    </HEAD>
    <BODY bgcolor="#B9B8B0">
    <!-- URL's used in the movie-->
    <!-- text used in the movie-->
    <!--BEST VIEWED AT 1024 x 768 RESOLUTIONALL PHOTOGRAPHS © 2004 MICHAL PFEILImagineEye--><div align="center"> <OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
    WIDTH="980" HEIGHT="600" id="ImagineEye" ALIGN="top">
    <PARAM NAME=movie VALUE="ImagineEye.swf"> <PARAM NAME=loop VALUE=false> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=scale VALUE=exactfit> <PARAM NAME=bgcolor VALUE=#B9B8B0> <EMBED src="ImagineEye.swf" loop=false menu=false quality=high scale=exactfit bgcolor=#B9B8B0 WIDTH="980" HEIGHT="600" NAME="ImagineEye" ALIGN="top"
    TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
    </OBJECT></div>
    </BODY>
    </HTML>
    Last edited by garion1; 03-09-2004 at 05:47 AM.
    "A day without laughter is a day wasted." - Charlie Chaplin

  3. #3
    Junior Member
    Join Date
    Jan 2004
    Location
    California
    Posts
    13

    Thanks but also want centered horizontally...

    That was so easy, thanks a lot for helping me out, wow. Though I would also like to center it horizontally as well and see how that looks. Again, appreciate all the help you guys can provide.

  4. #4
    I think I'm trying to do the same thing as you.

    Did you ever get your movie to get centered hort. also? If so I would really appreciate if you could help me out.

    Thanks!

  5. #5
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    a quick way to centre vertically and horizontally could be to use a table, something like this,

    Code:
    <html>
    <head>
    <title>my movie</title>
    </head>
    <body>
    <body>
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center" valign="middle">
    you object and embed tags in here
    </td>
    </tr>
    </table>
    </body>
    </html>
    however be careful with using a doctype on the page, since this relies on some non standard html (tables don't strictly have a height attribute) adding a doctype to the page may cause the browser to lose the vertical alignment of the movie. check this thread for more details.

  6. #6
    Thanks. But the true answer to my dreams is how do I get my flash movie to open in a centered window that is 715x430 and has no margins or scollbars.

    I've been trying for this all day but the only answers I can get is a script that tells me how to get one of those standard javascript buttons, and then when I click my movie will open in a centered window but the margins are still there pushing my movie down to the left.

    What I really need is to put the correct script into an image slice that is in a fireworks doc.

    So how do I select a image slice and place javascript code into it.

    Thanks for any help, my head is spilting from all the searching.

  7. #7
    Member
    Join Date
    Mar 2004
    Location
    Argentina
    Posts
    43
    There is an extension you can use to have Flash objects completely centered on html.

    Here is the file:
    Attached Files Attached Files

  8. #8
    Junior Member
    Join Date
    Jan 2004
    Location
    California
    Posts
    13

    The code doesn't work on PCs but only on Macs

    The second post from Garion with the html code only worked on Mac computers and when I tried loading my site on a PC all I got was white with nothing else. I guess that's why I use Flash and not html. So I guess I am back to square one unless I try the tables code.

    thanks

  9. #9
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    maybe you could try something like this,

    in the head of the page that you want to lauch the flash movie you could add a javascript function like this,

    Code:
    <script type="text/javascript">
    function openCentredWin(url, name, width, height) {
        var x = (screen.width - width) / 2;
        var y = (screen.height - height) / 2;
        newWin = window.open(url, name, 'width=' + width + ',height=' + height + ',left=' + x + ',screenX=' + x + ',top=' + y + ',screenY=' + y);
    }
    </script>
    then this could be called from an event in the page (a link being clicked, the onload event etc) eg,

    Code:
    <a href="javascript:openCentredWin('filename.html','flashWin',715,430);">click to open</a>

  10. #10
    Junior Member
    Join Date
    Jan 2004
    Location
    California
    Posts
    13

    Thanks a lot everybody especially Hamah

    Thanks everyone but especially Hamah since that extension did exactly everything I wanted it to do and works great everywhere I think. No more problems on the PC so I am loving it and dont' have to mess with the code.

    thanks

  11. #11
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    Useful extension Hamah. Thanks.
    "A day without laughter is a day wasted." - Charlie Chaplin

  12. #12
    Member
    Join Date
    Mar 2004
    Location
    Argentina
    Posts
    43
    No problem guys...

    You can also go to www.macromedia.com and download more useful extensions; check them out.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center