Groups | Blog | Home
all groups > flash actionscript > november 2005 >

flash actionscript : Stage Listener / Fullscreen Image


buckyball28
11/18/2005 9:06:09 PM
I've been researching this for a couple days. Not real code savvy. I basically
want to imitate this setup shown here of a large background image on some pages
that expands/collapses proportionally based on window size. While at the same
time, the buttons or other images stay the same size. Example:

http://landing.ancestry.com/military/vday/

Someone was kind enough to supply me an example .fla file. I think it's close
to what I need except for the fact that the background image doesn't scale
proportionally. Could someone take a look at the file and let me know what
needs to change to achieve this effect. File here:

http://www.fatemedia.com/scale.fla

Thanks
juankpro
11/18/2005 9:53:13 PM
Well, tomake the picture resize proportionatelly will cause one of two effects,
the picture to get crop (if you want the picture to occupy the hole flash) or
you will get empty spaces around the picture to make the picture scale with
proportions. Which onw you will want.
juankpro
11/18/2005 10:07:53 PM
The first function is for the first method and the second for the second
method, test both and select one:



myListener.onResize = function() {
var rate = Stage.height / Stage.width;
var imgRate = _root.bg._height / _root.bg._width;

if(rate > imgRate){
_root.bg._height = Stage.height;
_root.bg._xscale = _root.bg._yscale;
}
else {
_root.bg._width = Stage.width;
_root.bg._yscale = _root.bg._xscale;
}
};

myListener.onResize = function() {
var rate = Stage.height / Stage.width;
var imgRate = _root.bg._height / _root.bg._width;

if(rate < imgRate){
_root.bg._height = Stage.height;
_root.bg._xscale = _root.bg._yscale;
}
else {
_root.bg._width = Stage.width;
_root.bg._yscale = _root.bg._xscale;
}
};
buckyball28
11/21/2005 12:00:00 AM
Thanks juank. A couple of questions. It seems that both sets of code are the
same? Or am I just reading them wrong. Second, where would I apply this? On the
main timeline? And what size should I make my image? etc. etc.

thanks again.
juankpro
11/21/2005 12:00:00 AM
The size for your image doesn't really matter. I thas to be enoughly large for
not getting so much pixeled during scaling, but it has to be enoughly little so
that your application doesn't gets to heavy (in bytes size), if this is for a
CDROM size might not matter.

This code must be in the main timeline, but be carefull not to replace all
tour code with this one. Just replace the myListener.onResize function only. I
based this code on the one you sent, so replace the corresponding function
letting all the other code intact.

The only difference between the first code and the second one is that in the
if condition the first one uses the less than operator and in the second one it
uses the more than operator.
buckyball28
11/21/2005 10:10:41 PM
Juank, thanks so much. I finally put 2 and 2 together. Works great.

AddThis Social Bookmark Button