Flash mc positioning
- Started
- Last post
- 14 Responses
- wwfc
Afternoon! Sorry for posting another flash question but I am struggling to find a solution to this.
Is there a way of positioning a group of movieclips relatively to the centre of the stage.
I currently have this code on the clips:
onClipEvent(load)
{
startX = this._x;
}
- wwfc0
...
errgh! post cut off after the AS!Is there any way of positioning a group of mc's around the centre to set positions?
Anyone seen this before?
- chrisRG0
if your clips are centered registration point:
this._x = Stage._width / 2;
this._y = Stage._height / 2;
- chrisRG0
ops, sorry, i mean:
Stage.width and Stage.height (without the '_')
- wwfc0
...cheers chris - I'll give that a try
- wwfc0
...hmm! that doesn't seem to work - but thanks for the suggestion.
anyone know any other possible ways to do this?
- lvl_130
are you asking about a fixed size? or a floating point relative to the browser window? (ie. it always stays centered even if browser window is expanded)
- wwfc0
...yes, regardless of the browser width height etc... the mc's stay in set positions relative to the centre of the stage.
for example tile 1 is always say 10px to the left and 10px above the absolute centre...
does that make sense? hope so!
- jpea0
Maybe:
this._x = Stage.width / 2 - this._width/2
this._y = Stage.height / 2 - this._height/2The Stage doesn't have a property of _height or _width like movie clips, so take off the _ and it should work. If you need it to constantly change coordinates based on browser size, you'll need a listener.
- lvl_130
i sent myself something that i wrote in pastebin...still waiting for the email back...i thinks it broked
- wwfc0
thanks for that jpea...
...but wouldn't:
this._x = Stage.width / 2 - this._width/2
this._y = Stage.height / 2 - this._height/2
position all of the clips on top of one another in the very centre, rather than spacing them out?
- lvl_130
put this on frame 1 of your file.
Stage.scaleMode = "noScale";
Stage.align = "TL";
var stageListener:Object = new Object();
Stage.addListener(stageListener...
setBackground();
stageListener.onResize = function() {
setBackground();
};
function setBackground() {
//sets your mc to absolute pixel number
//uncomment out below to use this
/*
your_mc._y =76;
your_mc._x =10;
*/
//sets your mc to 100% browser height and width with scale
//uncomment out below to use this
/*
your_mc._width = Stage.width;
your_mc._height = Stage.height;
*///sets your mc to the center of browser height and width no scale
//uncomment out below to use this
/*
your_mc._y = Stage.height/2 ;
your_mc._x = Stage.width/2;
*/
}
- jpea0
yep. I thought you said you were working with clip events, which means your code is on top of clip rather than on the timeline. If you're working with code on the timeline somewhere, just use it's instance name instead.
myClip1._x = Stage.width / 2 - myClip1._width/2
myClip1._y = Stage.height / 2 - myClip1._height/2then to have one to the left of it,
myClip2._x = Stage.width / 2 - myClip1._x - myClip2._width - 10
myClip2._y = myClip1._ythat'll give it a buffer of 10 on the left. not sure if that's what you're looking for. seemed to be though...