Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Absolute Position

(115 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

OneSexyPaperBag

Reply To Post Reply & Quote

Posted at: 8/4/07 05:09 PM

OneSexyPaperBag LIGHT LEVEL 03

Sign-Up: 02/27/07

Posts: 57

Someone mentioned to me once that there was a command for finding the _x and _y of an object inside another Movie Clip in relation to _root.

Up until now I've just been using

actual_x = _parent._x+_x

to find absolute position. This gets really annoying after a few levels of MCs though. If someone knows the command I'm talking about I'd be grateful.


None

GuyWithHisComp

Reply To Post Reply & Quote

Posted at: 8/4/07 05:12 PM

GuyWithHisComp LIGHT LEVEL 23

Sign-Up: 11/10/05

Posts: 4,029

I think you're looking for localToGlobal()

BBS Signature

None

T-H

Reply To Post Reply & Quote

Posted at: 8/4/07 05:54 PM

T-H LIGHT LEVEL 38

Sign-Up: 01/07/04

Posts: 4,903

At 8/4/07 05:09 PM, OneSexyPaperBag wrote: This gets really annoying after a few levels of MCs though. If someone knows the command I'm talking about I'd be grateful.

To be honest I find globalToLocal / localToGlobal even more annoying to work with, they can be very buggy and unresponsive


None

Paranoia

Reply To Post Reply & Quote

Posted at: 8/4/07 06:09 PM

Paranoia DARK LEVEL 31

Sign-Up: 04/22/05

Posts: 9,115

At 8/4/07 05:54 PM, T-H wrote: To be honest I find globalToLocal / localToGlobal even more annoying to work with, they can be very buggy and unresponsive

Yeah, if you really find using levels of MCs annoying then I just reccomend writing your own function. Like:

function getFullPos(levs:Number):Array{
var cos:Array = [this._x, this._y];
levs > 1 ? (cos[0] += this._parent._x, cos[1] += this._parent._y]) : 0;
levs > 2 ? (cos[0] += this._parent._parent._x, cos[1] += this._parent._parent._y]) : 0;
levs > 3 ? (cos[0] += this._parent._parent._parent._x, cos[1] += this._parent._parent._parent._y]) : 0;
levs > 4 ? (cos[0] += this._parent._parent._parent._parent._x, cos[1] += this._parent._parent._parent._parent._y]
) : 0;
// if you really need any more than this you've got some serious nesting...
return [cos[0], cos[1]];}
;

Optimise away!

A rate of change in sanity with respect to time.

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 8/4/07 06:19 PM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,293

I do believe this will find the amount of MCs.

u = 0;
while (!found) {
u++;
(mc=_parent.mc) == '_level0' ? found=true : 0;
}

The reg lounge: a tale, a legend, a place full of fucking noobs.

BBS Signature

None

Toast

Reply To Post Reply & Quote

Posted at: 8/4/07 06:25 PM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,293

Anyway, unless Paranoia's function becomes really sophisticated: I recommend logcalToGlobal(); How to use:

var obj:Object = new Object();
obj.x = YourMovieClip._x;
obj.y = YourMovieClip._y;
localToGlobal(obj);

Then obj.x will give you the global position of local point yourmovieclip._x and obj.y will give you the global position of local point yourmovieclip._y;

The reg lounge: a tale, a legend, a place full of fucking noobs.

BBS Signature

All times are Eastern Daylight Time (GMT -4) | Current Time: 04:14 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!