Object hierarchy messed up?

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:

 
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 :(:

 
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!!

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.

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

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… :frowning:

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

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. :smiley:
[/offtopic]

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?

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.

But first make sure you gave instance names :wink:

The output is correct:

 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)

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??

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!

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

_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!

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.