A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Detecting Browser Height ?? AS2 / CS3

  1. #1
    An Englishman in Frankfurt Jimbrowski's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Detecting Browser Height ?? AS2 / CS3

    Hello All... here's my problem...

    I've created a .swf that scrolls photos across the screen and I want the user to be able to click a button to view a single photo at full size.

    All very simple... but in this case, the full size of the photo is dependent on the users available browser height...

    So what I really need is help detecting the users available browser height. My research tells me this can be done with a combination of JavaScript and the Flash External API but I can't quite workout how this should be implemented.

    Can anyone help ?? There's an apple and a biscuit in it for you ??

    Cheers
    Jimmy

  2. #2
    An Englishman in Frankfurt Jimbrowski's Avatar
    Join Date
    Nov 2006
    Posts
    240
    Come-on... surely some clever dude (or dudette) knows this ??

    Please help... Please help... Please help... Please help... Please help... Please help...

  3. #3
    Senior Member bomesar's Avatar
    Join Date
    Nov 2006
    Location
    Croatia
    Posts
    136
    Quote Originally Posted by Jimbrowski
    Come-on... surely some clever dude (or dudette) knows this ??
    So nothing for me to see here, huh?
    Oh well, I'll give it a try anyway... you can detect the height of the SWF file using Stage.height, for example:

    PHP Code:
    Stage.scaleMode "noScale";
    Stage.align "LT";
    stageListener = new Object();
    stageListener.onResize = function() {
        var 
    userHeight Stage.height//THIS IS WHAT YOU NEED
        
    trace (userHeight);
    }
    Stage.addListener(stageListener);
    stageListener.onResize(); 
    Quote Originally Posted by Jimbrowski
    Please help... Please help... Please help... Please help... Please help... Please help...
    Did you just copy paste that? You did, didn't you?!
    "Kreativa Studio - Izrada Flash Stranica"

    LATEST: Flash - Mareda Potrčko • HTML - MikrofonijaNew Layout Design - Tony Robbins || SOCIAL: on Twitteron Facebookon Kontain

  4. #4
    An Englishman in Frankfurt Jimbrowski's Avatar
    Join Date
    Nov 2006
    Posts
    240
    Yes I did, didn't I ??

    Cheers Mr Mesar... I might have to make some adjustments to my swf if I use Stage.height I suppose.

    Officially my stage is 1024 x 670 but I have elements outside of the stage area that are visible if the user is viewing on screens up to 1920 x 1200.

    If I was to maximize (+) my browser whilst viewing my swf, which is set to 1024 x 670, on my 1920 x 1200 screen, would Stage.height still return 670 ??

  5. #5
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    not if you EDIT *don't have the swf's width and height set at a percentage of the browser window in the html. If you give it a fixed dimension in the html then using a stageListener does you no good. So, use a percentage and it will work.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  6. #6
    An Englishman in Frankfurt Jimbrowski's Avatar
    Join Date
    Nov 2006
    Posts
    240
    Okay then cool... thanks very much guys....

    I'll give this solution a whirl in a few days time... because another job has landed in my lap that needs doing first... Dammit !!

    Cheers again... Jimmy

  7. #7
    An Englishman in Frankfurt Jimbrowski's Avatar
    Join Date
    Nov 2006
    Posts
    240
    Hey guys... I know this is a little old now but i've only just got the chance to work on it again...

    Now that we have the correct browser height (userHeight) can you tell me how to resize an MC containing a loaded .jpg image, to the newly discovered height of the browser (userHeight) ??

    I thought this part would be really simple, but i'm struggling big time !!

    Any help would be much appreciated... oh and Happy Xmas everyone

    Jimmy

  8. #8
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    PHP Code:
    Stage.scaleMode "noScale";
    Stage.align "LT";
    stageListener = new Object();
    stageListener.onResize = function() {
        var 
    userHeight Stage.height//THIS IS WHAT YOU NEED
        
    trace (userHeight);

       
    MyMCs._height userHeight;//This is the trick right here!
    }
    Stage.addListener(stageListener);
    stageListener.onResize(); 
    The image must be fully loaded before you resize the mc. If you want to load it and resize it automatically you might do

    PHP Code:
    var mcList:Object = {};
    var 
    mcLoad:MovieClipLoader = new MovieClipLoader();

    mcLoad.loadClip("MyJPG.jpg",someMConSTAGE);
    mcList.onLoadInit = function(target):Void{
        
    target._height Stage.height;

    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  9. #9
    An Englishman in Frankfurt Jimbrowski's Avatar
    Join Date
    Nov 2006
    Posts
    240
    Thanks mneil... these are exactly the 2 methods i've been struggling with..

    I still can't get it to work, but I think i'm making progress - where you've written "target" should I replace this with the name of the MC ??

    Cheers
    Jimmy

  10. #10
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    no, target is a parameter passed by onLoadInit and it is the name of the mc. In the example I've shown you it would be "someMConSTAGE". try tracing target inside the onLoadInit function;

    mcList.onLoadInit = function(target):Void{
    trace(target);//should trace the name of the mc you're loading the jpg into
    target._height = Stage.height;
    }
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  11. #11
    An Englishman in Frankfurt Jimbrowski's Avatar
    Join Date
    Nov 2006
    Posts
    240
    Cheers mneil... i've got it all working now thanks...

    However, even though i'm only resizing down (never up) the resized photo image looks terrible and that just won't be good enough for the client.

    Is there some setting i'm missing that might improve things ?? otherwise i'm thinking of creating a number of different sized versions of the photo image and have these chosen depending on the browser height...

    eg. If the users browser height is returned as 1115 px, the script will choose to pull-in the photo with the closest, lower height (1100 px).

    I can handle the script no problem, but if there's a better way, please let me know.

    Thanks again
    Jimmy

  12. #12
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    That's about all you can do. You can load in a large image, one that is maybe 1600 px wide by some number tall and resize it down when it loads, then if the user resizes to a larger image then it would always look good until you got someone viewing it with a screen wider than 23 inches or so. Or, you can get the screen resolution and load different sizes for each resolution.

    Anyway, the problem is the image quality, and there isn't anything you can do with code to fix that. You're right in assuming what you have.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

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