| Register
Sunday, May 11, 2008   

Mastering Full Browser Flash (Part 2)

Created By  Benjamin Mace, at  3/29/2005 - 19 comments.

Click to view this author's website.

As I discussed in my introduction article, Full Browser Flash (FBF) has recently become a large trend in Flash based site design. Its many benefits include seamless background and content integration as well as an unrestricted movie size compared with fixed stage sizes. So now that you know it's trendy and beneficial let's discuss how you can employ this technique.

Developing a FBF formatted site is relatively easy. I would say that this technique, outside of copying and pasting the following code, requires a minimal knowledge of ActionScripting.

The first thing you need to do in the HTML for you project is set the width and height parameters to use 100% scaling. We set our SWF size to be a percentage of the window vs. a pixel width allowing the resize in the window. This option has been around since the early, early days of Flash. Do the following within your object and embed tags:

This is the basic method for filling your browser window. You'll also notice the SWF is aligned to the top left. Our 0,0 coordinate for our SWF will be the top left just like in the Flash authoring environment. You'll also want to set the margin for the window to 0 in your body tag or CSS style sheet. This will insure there is no space between the SWF and browser chrome (outer window elements) when presented in the window.

Next up is setting the Flash movie to not allow scaling. As we have the HTML set now, your content will be stretched to fit the browser window regardless of its proportion or size. This will result in unwanted distortion of the SWF. To counter this, within the SWF, place the following ActionScript in your first frame:

This sets the Stage object's scale mode property to not allow scaling.

That's it! Pretty easy right? Now you can develop as you would and know that your stage can be as tall and wide as you user wants. In the next article we'll talk about setting up listeners to allow your content to react to the user resizing the browser window.


Need Professional Help For Your ActionScript Project?
ActionScript.com Consulting Services provide top quality professional ActionScript consulting to businesses around the globe. If you have a professional project in need to world-class talent, tell us about your project by requesting a quote today.

Reader Comments

  1. Dedé  Replied:
    ( 3/30/2005 At 12:47 AM)

    Hi Ben,
    I liked your articles about FBF and I'm implementing some of these tecniques on my client's sites.
    However, I'd like to see something about resizing the background(MC) when the stage is resized.
    Cheers,
    Dedé

  2. justin  Replied:
    ( 3/30/2005 At 1:11 AM)

    Dedé - look into adding a listener to the stage. Here is some basic info.
    http://moock.org/asdg/technotes/relayout/

  3. Benjamin Mace  Replied:
    ( 3/30/2005 At 2:49 AM)

    Stay tuned. I have 2 more coming. One on listeners for resizing and one on backgrounds/patterns.

  4. joeTEK  Replied:
    ( 3/30/2005 At 5:36 PM)

    Just a side note that may effect a few people ... this will not necessarily scale a Flash movie to fill all the vertical space available. This is because that "height='100%'" is not a valid W3C tag. Some browsers support it but others don't. This is especially the case when using XHTML. To get around it, don't use XHTML. To view a site that uses that and works in every browser I've tested it in just "view source" at http://www.dynamicwebtraining.com.au/flash/ and grab the relevant HTML and style tags.
    J

  5. bassmonkey  Replied:
    ( 3/30/2005 At 9:46 PM)

    any chance of a simple .fla that demonstrates this..

  6. freaksauce  Replied:
    ( 4/1/2005 At 10:11 AM)

    As joeTEK commented a Flash movie will not scale to 100% in some browsers, Firefox for example due to the non valid height attribute, check out the simple fix over at Bit-101.

  7. Igor Costa  Replied:
    ( 4/3/2005 At 8:26 AM)

    Ben, you can take a look that much more usefull to all users when we talk about Full screen that why don't pass parameters with javascript instead html tags?
    Remembers some Navigators give a feedback errors.

  8. Slade  Replied:
    ( 5/14/2005 At 4:35 AM)

    This is a very interesting subject to me... Will this work on a PHP server? I know a little flash and even less PHP but I am stuck working both on one of my sites.

  9. Anthony Graddy  Replied:
    ( 5/31/2005 At 7:00 PM)

    Yeah, this will work on a PHP server. Anything that can be done with HTML can be done with PHP. PHP is just a script that is run on a server before the HTML is generated.

  10. Steve Reynolds  Replied:
    ( 6/13/2005 At 10:36 AM)

    It's about time someone started talking about this. I see people put Flash in certain sections of a site when the whole site should be Flash. Yes it is more work, but it looks 1000 times better.
    In any case I have been working on this site (http://www.xsxtreme.com/) for a while and, as you can see, I have implemented PHP, AS2, and FLV video. The possiblites for using these technologies are endless, just have the patience to figure it out. Keep up the articles, as I will be checking back for some new tricks that I might be able to use on my site.

  11. Dips  Replied:
    ( 8/26/2005 At 10:55 PM)

    HI
    I've typed the following into the HTML file:


    scaling

    <style="margin:0px;">
    WIDTH="100%" HEIGHT="100%" id="stage" ALIGN="top">





    <embed src="scaling.swf" menu=false quality=high salign=LT bgcolor=#999999 WIDTH="100%" HEIGHT="100%" NAME="stage" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
    <object>


    And it is still not working - any help would be very very much appreciated
    thanks in advance
    Dips

  12. Dips  Replied:
    ( 8/27/2005 At 2:08 PM)

    Hi everyone
    I've already checked out "Mastering Full Browser Flash (Part 2)"
    Still with no joy...would anybody be able to help me out?
    Cheers

  13. Lester  Replied:
    ( 9/12/2005 At 7:53 PM)

    Hello, I inserted the code above but when you maximize the browser, the Logo is distorted. How come it is distorted? Anyone?
    http://www.julesrealty.com/test

  14. Snottlebocket  Replied:
    ( 9/28/2005 At 1:42 PM)

    Lester did you add the bit of actionscript in the first frame that says
    Stage.scaleMode = "noScale";
    the html alterations make sure the flash file stretches the full width and height of the browser.
    the bit of actionscript makes sure that your flash content doesn't stretch and warp on the stage along with it.

  15. mediadog  Replied:
    ( 10/13/2005 At 7:13 PM)

    I've got this working in a browser window, but I want it to use it for a fullscreen executable CD-Rom.
    For example, I want to put a navigation movieclip in the bottom left of the screen, and a company logo in the top right. I can do this in a browser window, but when I make an exe it doesn't work the same.
    Any suggestions? Or can someone point me in the direction of a tutorial for it perhaps??

  16. Geezabloke  Replied:
    ( 10/30/2005 At 7:27 PM)

    rather than adding the noscale AS into the flash file just add this to the tags when embedding the flash

  17. k16903  Replied:
    ( 11/3/2005 At 5:45 PM)

    Ello,
    if layer 0 is set to 100%, then I set the swf on layer 1 to noscale --- it sets the layer 0 to noscale too -- is there a way around this?
    Cheers

  18. Lazlo  Replied:
    ( 11/5/2005 At 4:49 AM)

    Is there anybody that can clue me in on how Joshua Davis handled his FBF site? The interfaces stays centered vertically, and only the right section of the site changes width. Is that right section just VERY VERY long? Or is it changing dynamically with the browser?
    http://www.joshuadavis.com
    Thanks!
    Laz

  19. steve  Replied:
    ( 12/13/2005 At 11:01 AM)

    Hello the site I am working with has a small issue (right now many.. but I m working on it)
    Upon load images to not repostion, however upon resize they do.

    If any one can direct me to answer that would be a wonderful thing!

  20. Login to post your comments. If you do not have an account with us please Register.

Copyright 2005 by ActionScript, Inc.   |  Privacy Statement  |  Terms Of Use  |  ActionScript Client Extranet