PDA

View Full Version : Centering a nested object to the stage.



nathan99
June 18th, 2005, 01:49 AM
hoy hoy,
I have a picture of a mine which is nested within an object, nested within another obect. Now what i want it that on the keypress of shift, i creates the mine image at the same postion of the tank.

The issue is that the main obect that is nesting the mine moves, thus not creating at the the center, rather on that postion of the object.

here are how my images go by instance names;
1. Tank Stays in the center
//////
/////
1. Land (moves) -- 2b. map -- 3b. All objects that hitTest
|
2a. Objects
|
3b. All the objects that dont get hit(in here is my mine.)

icio
June 18th, 2005, 05:31 AM
i'm assuming that your tank is in `_root`:

point.x = tank._x;
point.y = tank._y;
theMovieClipWithMinesInIt.globalToLocal(point);
//...
the `point.x` and `point.y` variables now include the position within the movieclip for mines for where the mines should be placed.

nathan99
June 18th, 2005, 10:02 PM
nope didnt work

nathan99
June 19th, 2005, 01:19 AM
it doesnt work because it is an object within an obect, and it is going to the right postion just to the position of its parent mc, i need to to go to that postion of the main stage, whilst it is in that mc...

icio
June 19th, 2005, 08:42 AM
.fla ? that should work. you are puting in the full path to that movieclip, correct ?