PDA

View Full Version : Full flash problem...again



fried
November 13th, 2006, 05:53 AM
Hi guys,
I am using this script:


Stage.scaleMode = "noScale";

Stage.align = "LT";

box2._x = Math.round((Stage.width/2)-(box2._width/2));
box2._y = Math.round((Stage.height/2)-(box2._height/2));

box2.onResize = function() {
box2._x = Math.round((Stage.width/2)-(box2._width/2));
box2._y = Math.round((Stage.height/2)-(box2._height/2));
};
Stage.addListener(box2);
box2.onResize();

When loading an external swf into box2, the code does not move the box to the middle when the browser is rescaled. What is the problem?

999
November 13th, 2006, 07:25 AM
By assigning the listener to box2 your killing it when you load into it. Create a new object to listen for the resize function instead. I've never heard of "LT" before? I think you mean "TL"?


Stage.scaleMode = "noScale";
Stage.align = "TL";
stageListener = new Object();
setStage = stageListener.onResize=function () {
box2._x = Math.round((Stage.width/2)-(box2._width/2));
box2._y = Math.round((Stage.height/2)-(box2._height/2));
}
setStage();
Stage.addListener(stageListener);

/*In your MovieClipLoader or preloader call setStage()
to center box2 on init or just put an OnClipEvent
directly on it */

onClipEvent(load) {
_parent.setStage();
}

fried
November 13th, 2006, 08:00 AM
Thanks 999, works perfectly.