flashMX center Q
- Started
- Last post
- 8 Responses
- stewart
i have made a flash file that centers a MovieClip on the stage with ._x=Stage.width/2 including a sliding transition:
http://www.kulsdom.com/newstoday…the question is:
how can i center this MC on exact coordinates like lets say x300/y200 and not at x300.2/y200.7 ??
- F_180
try loading it into an empty movie clip on the stage that is positioned to your desired coordinates. by the way, what line of code do you use to have the flash movie re-position itself within the browser window? been wondering about that??
- unfittoprint0
MC._x=Math.round(Stage.width/2);
MC._y=Math.round(Stage.height/2...
- unfittoprint0
real 'centering':
MC._x=Math.round((Sta ge.width-MC._width)/2);
MC._y=Math.round((Sta ge.width-MC._height)/2);
- stewart0
oooowkaaaay...
Math.round
the discovery of the month.thanks alot.
- stewart0
F18, try this:
----
in the first frame of your fla file:
----
Stage.scaleMode = "noScale";
Stage.align = "LT";
Stage.addListener(MC);----
in your MovieClip actions:
----
onClipEvent (enterFrame) {
_root.MC.onResize = positionMC;
function positionMC() {
endX = (Stage.width/2)-(_root.MC._width...
endY = (Stage.height/2)-(_root.MC._heig..._root.MC._x = endX;
_root.MC._y = endY;
}
positionMC();
}
- F_180
you are too kind...thanx.
- unfittoprint0
stewart,
I beg to differ regarding the onClip event. With that your movie is constantly centering the mc even when that's not necessary, therefore spending much more processor resources [and making the overall functionality much, much slower with each asset 'thrown' into Stage].
you should use a listener to trigger a center function ONLY when the Stage is resized:
//________ RESIZE
Stage.align = "LT";
Stage.scaleMode = "noScale";
center = function () {
mc._y = Math.round((Stage.height-mc._hei...
mc._x = Math.round((Stage.width-mc._widt...
};
Reziser = new Object();
Stage.addListener(Reziser);
Reziser.onResize = function() {
center();
};
- stewart0
hey unfit,
i didn't gave the full script when i explained the Q.
i use an addListener indeed.
thanks anyway!