# Object hierarchy messed up?

**URL:** <https://forum.kirupa.com/t/object-hierarchy-messed-up/60941>\
**Category:** flash\
**Created:** [August 13, 2004, 11:03pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941 "2004-08-13T23:03:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferdi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ferdi/32/689_2.png) [@Ferdi](https://forum.kirupa.com/u/Ferdi)\
**Post date:** [August 13, 2004, 11:03pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/1 "2004-08-13T23:03:21Z")

</div>

Hi people!  
I’m experiencing this weird problem with my new flashgame I’m currently writing.

The problem is that I try to obtain the x and y location of an object somewhere in a hierarchy. It doesn’t work. What does work though is when I try to get the x and y location of the parent of that hierarchy. This is what it looks like with the full hierarchy:

```auto
 
this._x = _root.MVPlayer.PlayerArm.PlayerGun._x;
this._y = _root.MVPlayer.PlayerArm.PlayerGun._y;
this._rotation = _root.MVPlayer.PlayerArm.PlayerGun._rotation;

```

The code above doesn’t work. though when I restrict it to the parent like this, it does work. But that’s not what I want :(:

```auto
 
this._x = _root.MVPlayer._x;
this._y = _root.MVPlayer._y;
this._rotation = _root.MVPlayer._rotation;

```

All the objects you see here have an instance name.  
Any help would be very much appreciated! Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2004, 11:09pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/2 "2004-08-13T23:09:26Z")

</div>

i guess you already checked for typing mistakes for about 100 times, but just try it one more time… maybe you could post your .fla… then we can see for ourselves… because its difficult to help this way.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2004, 11:18pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/3 "2004-08-13T23:18:17Z")

</div>

Thanks 2nd day, but I’m not allowed to post the raw materials.  
\*\*\*\* contracts ☹

I checked for spelling errors and also selected the path through the hierachy selector thing, and there’s nothing wrong with the path.

I think it’s weird… ☹

EDIT: btw 2nd Day, I’ve been to eerbeek 2 weeks ago hehe, Camping Coldenhoven!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2004, 11:25pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/4 "2004-08-13T23:25:41Z")

</div>

well, then i don’t know what to do… maybe you could try other ways… like doing it with actions in a frame: \_root.thatmc.\_x = \_root.MVPlayer.PlayerArm.PlayerGun.\_x;  
or maybe in a frame in the PlayerGun mc … like this. \_root.thatmc.\_x - this.\_x;

[offtopic]  
so you’ve been to eerbeek, well i’m not so proud to live in eerbeek, but i never thought somebody on this forum would have ever been in eerbeek. 😃  
[/offtopic]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 7:36am UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/5 "2004-08-14T07:36:10Z")

</div>

Thanks, well there are ways like that to solve it I guess, but I need to know what causes this in order to avpod this trouble later on.

So maybe someone else experienced this before?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 8:29am UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/6 "2004-08-14T08:29:19Z")

</div>

just trace out some values as you step down your chain, like this:

[AS]  
trace(\_root.MVPlayer.\_name);  
trace(\_root.MVPlayer.PlayerArm.\_name);  
trace(\_root.MVPlayer.PlayerArm.PlayerGun.\_name);  
[/AS]

when you get **undefined** that’s when you have a mistake.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 8:38am UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/7 "2004-08-14T08:38:19Z")

</div>

But first make sure you gave instance names 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 10:35am UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/8 "2004-08-14T10:35:08Z")

</div>

The output is correct:

```auto
 MVPlayer
PlayerArm
PlayerGun

```

But when I trace the positions it’s getting weird:  
(note that the arm is connected to the MVPlayer(which is his body) and the gun to PlayerArm)

```auto
MVPlayer x: 275
MVPlayer y: 191.15
PlayerArm x: -6.3
PlayerArm y: -17.8
PlayerGun x: 12.5
PlayerGun y: 1.75

```

The arm is rotating around it’s pivot point so that should also be somewhere around 275x191, right??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 11:35am UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/9 "2004-08-14T11:35:37Z")

</div>

well it’s rotating around 275-6.3 (because PlayerArm is located IN MVPlayer at x = -6.3) and 191.15-17.8… or am i wrong?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 2:13pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/10 "2004-08-14T14:13:58Z")

</div>

> [@2nd day](#):
>
> well it’s rotating around 275-6.3 (because PlayerArm is located IN MVPlayer at x = -6.3) and 191.15-17.8… or am i wrong?

hmm, you could be right actually. So that means that it gets the relative position coordinates.

Thanks man, I think you’re right. I’ll check it out later and let you know! Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 5:58pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/11 "2004-08-14T17:58:15Z")

</div>

I’ve got it to work now, with the following script (though I think it’s VERY weird):

```auto
_root["MVbullet"+a]._y = _root.MVPlayer._y + _root.MVPlayer.PlayerArm._y - _root.MVPlayer.PlayerArm.PlayerGun._y;

```

Thanks for your help guys!! I really appreciate it!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2004, 8:35pm UTC](https://forum.kirupa.com/t/object-hierarchy-messed-up/60941/12 "2004-08-14T20:35:32Z")

</div>

Try localToGlobal? I have noticed that accessing something like mc.innerMC.\_x will output innerMC’s \_x relative to mc, and localToGlobal converts that to coordinates relative to the stage.
