PDA

View Full Version : Center in the Browser


atropper
06-04-2008, 04:06 PM
Hello,
i have one movie clip that i am trying to center and resize whenever the browser window resize. this is the code i am using: (container is my movie clip instant name)

Stage.align = "TL";
Stage.scaleMode = "noScale";

Container._x = Stage.width/2;
Container._y = Stage.hieght/2;

sizeListener = new Object();
sizeListener.onResize = function(){

Container._x = Stage.width/2;
Container._y = Stage.hieght/2;

}

However,when i test it, (F12) the file dosent resize as i expected? and when i publish it (Ctrl+Enter) it dose seems to work.
Anyone have any idea why? Also how can i be sure it will resize correctly in Safari,FireFox browsers as well?
Thanks

zizther
06-04-2008, 06:11 PM
Hey man,

is this something like you mean?

www.mediaofmulti.com/align

mess around with the browser size, it works in all browsers

if you want the .fla file here it is:

www.mediaofmulti.com/align/align.zip

atropper
06-04-2008, 08:55 PM
yes, thats exactly what i meant,
i will give the file a try,
Thank you very much.

asf8
06-05-2008, 04:25 AM
Hello, i have one movie clip that i am trying to center and resize whenever the browser window resize. this is the code i am using: (container is my movie clip instant name)

Stage.align = "TL";
Stage.scaleMode = "noScale";

Container._x = Stage.width/2;
Container._y = Stage.hieght/2;

sizeListener = new Object();
sizeListener.onResize = function(){

Container._x = Stage.width/2;
Container._y = Stage.hieght/2;

}

However,when i test it, (F12) the file dosent resize as i expected? and when i publish it (Ctrl+Enter) it dose seems to work.
Anyone have any idea why? Also how can i be sure it will resize correctly in Safari,FireFox browsers as well?
Thanks

You need to use a Stage Listener + onResize

stop();
Stage.scaleMode = "noScale";
Stage.align = "TL";
var myListener:Object = new Object();
myListener.onResize = function () {
// if the MC reg point is Top Left
Container._x = Stage.width/2-Container._width/2;
Container._y = Stage.height/2-Container._height/2;
/* or .... if the MC reg point is Center
Container._x = Stage.width/2;
Container._y = Stage.height/2;
*/
}
Stage.addListener(myListener);
myListener.onResize();

etc...