A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: How to keep center of the movie in the centre of the scree regardless of browers size

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    17

    How to keep center of the movie in the centre of the scree regardless of browers size

    Hi
    My flash movie is 1440x900 but the area where all the important stuff happens in within 1024x768, i am trying to keep the middle in the center regardless of browers size or aspect ratio.

    I can center the page but it doesn't work as i need it to. If the browers is small (1024x768) the swf is justified against the left edge, but not keeping the middle in the middle of the brower.

    http://www.luhringaugustine.com/ is an example of exactly what i am trying to achieve.

    I'm guessing this must be quite simple...any help is greatly appreciated!!

    Poly

  2. #2
    the naked eye waynenort's Avatar
    Join Date
    Jan 2002
    Location
    Melbourne, Australia
    Posts
    334
    code:
    your_mc._x = Stage.width / 2
    your_mc._y = Stage.height / 2


  3. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    17
    thanks for the replyt, thats a very elegant solution

    but i can i get this script to apply to everything in my site?

    do i need to load my site into a movie clip first? and apply it to that mc?

    thanks

  4. #4
    the naked eye waynenort's Avatar
    Join Date
    Jan 2002
    Location
    Melbourne, Australia
    Posts
    334
    Select the frames on you timeline that apply to the objects that need to be centered. Right click on the frames and select 'cut frames' from the pop up dialogue box.
    Goto 'insert' on the top menu and select 'new symbol', type what you want it called, then hit 'OK'.
    Select the first blank frame in your MC timeline, right click and 'paste frames'.
    Go up to the top headings in you timeline and select 'Scene1' - Which should close you newly created MC and take you back to the original timeline.
    Finally goto your 'Library' menu and drag your newly created MC onto the stage. Oh and don't forget to give your newly created MC an instant name that's the same as whats in your centering code (your_mc)

    If your original code on the timeline contains ._root and ._parent references, you may also have to alter these to suit the new structure.

  5. #5
    Junior Member
    Join Date
    Aug 2008
    Posts
    17
    That works perfectly many thanks!

    Actually, no i'm still having problems....
    When i preview the swf from flash it works great, but then i publish the movie and play the swf it shows the entire movie and scales in relation to the width of the flash player....

    There are no settings i can see for exporting swfs that could help?.... confused
    Last edited by poly55; 03-24-2009 at 06:24 AM.

  6. #6
    the naked eye waynenort's Avatar
    Join Date
    Jan 2002
    Location
    Melbourne, Australia
    Posts
    334
    How I understand your .swf is enlarging when the movie is say enlarged to the monitor width.
    If you want the .swf content remain the same size use
    code:
    Stage.scaleMode = "noScale"


  7. #7
    Junior Member
    Join Date
    Aug 2008
    Posts
    17
    many thanks waynenort,

    that has solved viewing the swf in the movie player but there is still a problem when opening the swf in a web browser. The html code centers the movie when the browser is bigger than the movie but when the browser is smaller than the movie the swf is justified against the left edge, not keeping the center in the center at all times as i need. Any thoughts?

  8. #8
    the naked eye waynenort's Avatar
    Join Date
    Jan 2002
    Location
    Melbourne, Australia
    Posts
    334
    Post your html link with the problem

  9. #9
    Junior Member
    Join Date
    Aug 2008
    Posts
    17
    http://www.gelpdesign.com/nv/ is my site.

    I need the main light box image to remain central if the browser is say being viewed on 1024x768

    many thanks for your help

  10. #10
    the naked eye waynenort's Avatar
    Join Date
    Jan 2002
    Location
    Melbourne, Australia
    Posts
    334
    Open your html in dreamweaver and alter your Flash movie's 'width' and 'height' in the 'properties box': w = 100% h =100%. If it's to be scale proportionally then make sure 'scale' in the dreamweaver 'properties box' says "Default (Show all)". Otherwise this can be set to "Exact fit" which allows your Flash movie to also fill the browser but may stretch it out of proportion slightly.

  11. #11
    Junior Member
    Join Date
    Aug 2008
    Posts
    17
    Thanks for the advise waynenort but i think you have misunderstood my original problem.

    I need to keep the middle of the site in the middle of the browser at all times.

    This is anticipating someone using a browser running at 1024 x 768. At is stands the site is justified against the left edge when the broswer size is reduced.


    this site behaves as i need mine to.
    http://www.luhringaugustine.com/

    Thank you.

  12. #12
    Member
    Join Date
    Nov 2008
    Posts
    66
    This can be done using CSS.

    Something along these lines.
    Code:
    object { position: absolute;
    		 left: 50%;
    		 top: 50%;
    		 margin-top: -(half of flash's height);
      		 margin-left: -(half of flash's width;
    		 
    	}
    Just change how it's applied to your embedded flash as you need it to be, this will center your flash as you've described.

  13. #13
    Junior Member
    Join Date
    Aug 2008
    Posts
    17
    thanks Zettl, so where does that need to sit in my html?? i have this at the moment....

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>NickVeasey</title>
    </head>
    <body bgcolor="#ededed">
    <!--url's used in the movie-->
    <!--text used in the movie-->
    <!-- saved from url=(0013)about:internet -->
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="nickveasey" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="allowFullScreen" value="false" />
    <param name="movie" value="nickveasey.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ededed" /> <embed src="nickveasey.swf" quality="high" bgcolor="#ededed" width="100%" height="100%" name="jonathanlappinphotos" align="middle" allowScriptAccess="sameDomain" allowFullScreen="flase" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </object>
    </body>
    </script>
    </html>

  14. #14
    Junior Member
    Join Date
    Aug 2008
    Posts
    17
    sorted it!!! ta

Tags for this Thread

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