-
An Englishman in Frankfurt
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
-
An Englishman in Frankfurt
Come-on... surely some clever dude (or dudette) knows this ??
Please help... Please help... Please help... Please help... Please help... Please help...
-
Senior Member
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();
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?!
-
An Englishman in Frankfurt
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 ??
-
Developing For Dunkets
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.
-
An Englishman in Frankfurt
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
-
An Englishman in Frankfurt
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
-
Developing For Dunkets
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; }
-
An Englishman in Frankfurt
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
-
Developing For Dunkets
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;
}
-
An Englishman in Frankfurt
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
-
Developing For Dunkets
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|