A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Centering Flash

  1. #1
    Member
    Join Date
    Mar 2005
    Posts
    40

    Centering Flash

    What should I do to make my Flash site open in the center of the browser. I went to Publish Settings and done the HTML alignment, but it didn't worked... Any suggestions?

  2. #2
    Member
    Join Date
    May 2004
    Posts
    71
    There is a dropdown menu that tells the HTML where to go on the site. There are two actually if I'm not mistaken. I think I used default/center and it worked well enough.

  3. #3
    Member
    Join Date
    Mar 2005
    Posts
    40
    I'm not sure what do you mean...

    I give you this picture showing my Publish Settings stats... Just take a look and diagnose...
    Attached Images Attached Images

  4. #4
    Ancient Member
    Join Date
    Nov 2000
    Location
    Somewhere
    Posts
    139
    I always centered my flash by editing the .html file and putting a
    Code:
    <center>  </center>
    around the flash object.
    It's nice to be important, but it's more important to be nice." - Hans-Peter Geerdes

  5. #5
    Member
    Join Date
    Mar 2005
    Posts
    40
    Where do I have to exactly put the <center> code??
    I launched Dreamweaver and pasted it in my .html file after publishing it in Flash... It didn't work. Please, show me the step-by-step instructions, 'cos I'm really a beginner...

  6. #6
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Go to the flash publish settings (file > publish settings) and make sure you have the html option selected. Then publish the swf and html files.

    Open the html file that was created in a text/web page editor (eg dreamweaver, notepad etc) then somewhere between the opening <head> and closing </head> tags add the following,

    Code:
    <style type="text/css">
    #movie {
        position: absolute;
        left: 50%; top: 50%;
        margin: -200px 0 0 -250px;
    }
    </style>
    and then just before the opening <object> tag in the page add

    <div id="movie">

    with a closing

    </div>

    just after the

    </object>

    tag.

    This part of the css

    position: absolute;
    left: 50%; top: 50%;

    positions the div tag containing the movie so that its top left corner is centred in the browser, to get the movie so the centre of the movie is in the centre of the browser we then nudge the movie up and to the left with some negative margins,

    margin: -200px 0 0 -250px;

    note that the value -200 should be minus half the height of your movie and the -250 should be minus half the width of your movie (so in this example the movie was 500 pixels wide and 200 pixels high) if your movie is a different size you'd need to adjust the values accordingly.

  7. #7
    Member
    Join Date
    Mar 2005
    Posts
    40
    Thanks. It works, although I got two mini-problems.

    My movie is 760x537, so according to your hints, I should have margins -360px and -268.5. Somehow it's not in the center but upper-middle sort of place. I wonder why...

    The second thing is my Safari browser doesn't show any changes I did in web page editor, it doesn't allow JavaScript to work. Do you know is there any possibility to make Safari see the changes I did in html??

    Ahh... I would be grateful if you could write how to make a html site to be in the center of a browser.

  8. #8
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    the following works for me in all the browsers I have here (opera, firefox and internet explorer) sorry, I don't have a mac so I can't test safari.

    Code:
    <HTML>
    <HEAD>
    <meta http-equiv=Content-Type content="text/html;  charset=ISO-8859-1">
    <TITLE>centred</TITLE>
    <style type="text/css">
    #movie {
        position: absolute;
        left: 50%; top: 50%;
        margin: -269px 0 0 -380px; /* rounded from 268.5 */
    }
    </style>
    </HEAD>
    <BODY bgcolor="#FFFFFF">
    <div id="movie">
    <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="760" HEIGHT="537" id="centred" ALIGN="">
     <PARAM NAME=movie VALUE="centred.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="centred.swf" quality=high bgcolor=#FFFFFF  WIDTH="760" HEIGHT="537" NAME="centred" ALIGN=""
     TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
    </OBJECT>
    </div>
    </BODY>
    </HTML>

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