Forum Topic: _X and _Y with embedded objects

(83 views • 6 replies)

This topic is 1 page long.

<< < > >>
Questioning

IzaacBarratt

Reply To Post Reply & Quote

Posted at: 9/27/09 10:43 AM

IzaacBarratt LIGHT LEVEL 13

Sign-Up: 10/19/07

Posts: 55

Currently working on a game and everything was going fine until I attempted to use _x and _y on an embedded object.

eg:
this._x=_root.gun._x;
this._y=_root.gun._y;

Works perfectly fine, but this on the other hand.

this._x=_root.gun.arm._x;
this._y=_root.gun.arm._y;

For some reason when I attempt to re-direct it to an embedded object the _x and _y properties act differently.
Does anyone know how to solve this proble,?


Elated

VinceDash

Reply To Post Reply & Quote

Posted at: 9/27/09 11:06 AM

VinceDash LIGHT LEVEL 14

Sign-Up: 11/06/07

Posts: 64

At 9/27/09 10:43 AM, IzaacBarratt wrote: Currently working on a game and everything was going fine until I attempted to use _x and _y on an embedded object.

eg:
this._x=_root.gun._x;
this._y=_root.gun._y;

Works perfectly fine, but this on the other hand.

this._x=_root.gun.arm._x;
this._y=_root.gun.arm._y;

For some reason when I attempt to re-direct it to an embedded object the _x and _y properties act differently.
Does anyone know how to solve this proble,?
this._x=_root.gun._x + _root.gun.arm._x;
this._y=_root.gun._y + _root.gun.arm._y;

When you say _root.gun.arm._x, it looks a the x coordinnate of the "arm" in the "gun" and not in the stage.

I know the name sucks...

BBS Signature

None

Yambanshee

Reply To Post Reply & Quote

Posted at: 9/27/09 11:17 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,587

when your referring to object1.object2._x your looking at object2's _x position on object1's coordiante grid. so as mentioned before, this._x = object1.object2._x

if object1 is rotating though, things can start to get tricky sometimes.

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

IzaacBarratt

Reply To Post Reply & Quote

Posted at: 9/27/09 12:05 PM

IzaacBarratt LIGHT LEVEL 13

Sign-Up: 10/19/07

Posts: 55

Thanks,
I understand the problem now but I don't know how to fix it.
Anybody know how??


None

milchreis

Reply To Post Reply & Quote

Posted at: 9/27/09 12:14 PM

milchreis DARK LEVEL 16

Sign-Up: 01/11/08

Posts: 446

localToGlobal ?

"Even if it's just cynicism that remained to push us ahead, we'll carry on!"


Questioning

IzaacBarratt

Reply To Post Reply & Quote

Posted at: 9/27/09 01:55 PM

IzaacBarratt LIGHT LEVEL 13

Sign-Up: 10/19/07

Posts: 55

Anyone Else?


None

UnknownFury

Reply To Post Reply & Quote

Posted at: 9/27/09 01:59 PM

UnknownFury EVIL LEVEL 26

Sign-Up: 08/10/05

Posts: 6,027

You've been given the solution. Either:

this._x=_root.gun._x + _root.gun.arm._x;
this._y=_root.gun._y + _root.gun.arm._y;

By adding the position of the MCs parent you're getting its position relative to the stage. The other option is to use the localToGlobal function.

Portfolio(Under construction): UnknownFury.com |
Msn: giant_ak_47@msn.com | Contact: me@unknownfury.com
Follow me on twitter!


All times are Eastern Standard Time (GMT -5) | Current Time: 10:54 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!