A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: swfobject.js centering

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Posts
    131

    swfobject.js centering

    i'm using the swfobject.js script to embed my flash movie. works great. however, is there a way to center the movie horizontally, and not vertically? i would like the file aligned to the top.

    i tried to search on the forums, but couldn't find it -- the wording is difficult. i am unfamiliar w/ js, so i'd be grateful for any help.

    thanks!
    jwt

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,046
    That has nothing to do with the swfobject. It's all about the containing <div> element. You can style that with any css you would like, for example positioning.

    So you could simple add the style attribute: <div id="myflash" style="align:center">

  3. #3
    Senior Member
    Join Date
    May 2007
    Posts
    266
    style="align:center"
    Never knew of this attribute before

    To center a div horizontally style ="margin:0 auto" This gives 0 margin at the top and bottom and auto makes the margins the same on the left and right. If your movie is 800px wide the margin would be the same for left and right of the remainder of the screen not used by the 800px.

  4. #4
    Senior Member
    Join Date
    Feb 2003
    Posts
    131
    thanks you guys for the options and clarification! i'll try it out.

    thanks again,
    jwt

  5. #5
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,046
    err, yeah, sorry about that, i meant: <div id="myflash" align="center">

    There is no 'align' css attribute. Your margin method would work too.

    Thanks for pointing that out.

  6. #6
    Senior Member
    Join Date
    Feb 2003
    Posts
    131

    it works, but...

    thanks for your help again. it did work, HOWEVER...

    in my flash movie, i disable scaling:

    Stage.scaleMode = "noScale";

    by doing so, it seems to override the align and the flash is centered vertically -- cutting off the top on a small browser. if i remove the noScale, it correctly aligns to the top.

    i'd prefer to keep the noScale on, as it improves performance and quality of visit. if there is no solution i guess i'll have to make a hard choice. thanks again.

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    You may want to look into Stage.align if you haven't already...I can't see your page to see exactly what's happening, but it may help.

  8. #8
    Senior Member
    Join Date
    Feb 2003
    Posts
    131

    resolved

    giddy-up.

    well, rdoyle720, i did have that Stage.align script in my code -- but i did research as you advised and found that i had not put the proper syntax in it.

    orig:
    Stage.scaleMode = "noScale";
    Stage.align = T;

    final:
    Stage.scaleMode = "noScale";
    Stage.align = "T";

    thanks everyone for helping me get a grasp on this. the site works properly now!

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