A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to resize an image depending on the browser size? - pls help

  1. #1
    Senior Member
    Join Date
    Jun 2001
    Location
    Swe
    Posts
    378

    How to resize an image depending on the browser size? - pls help

    Hi

    I'm wondering how to resize a background image depending on the browser window size, so that the user always can view 100% of the image. But it should be proportional scaling.

    You can view a perfect example of this over at http://www.puma.com/

    The effect I want is that the background scales dynamically dependeing on the browser window size but the size of the content stays static.


    I have no problem setting the size of the content static using listeners with Stage.scaleMode = "noScale";

    But I have no idea on how to scale the background image (MC) proportionally depending on the browser window size.


    Any help would be appreciated
    Thanks

  2. #2
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    first you need to make sure, that the flash fills all of your browser window,
    then inside flash you might use this code:
    code:
    Stage.scaleMode = "noScale"
    var myListener:Object = new Object();
    myListener.onResize = function () {
    trace("Stage size is now " + Stage.width + " by " + Stage.height);
    }
    Stage.addListener(myListener);
    // later, call Stage.removeListener(myListener)



    Btw. this code is taken 1:1 outta flash help about "onResize"

  3. #3
    Senior Member
    Join Date
    Jun 2001
    Location
    Swe
    Posts
    378
    yep flash fills the browser window

    I saw that example code in the help section. that code just traces the width and height of the stage.

    how can I use that to resize an MC?

  4. #4
    Member
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    87
    you would do something like...
    ratio=normalHeight/normalWidth
    then go mc._width=stageWidth;
    mc._height=mc.width*ratio
    or something like that... maybe
    that is asuming that the width is smaller than the height.

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