[mx] help!

ok within this is my boss for my game (which was too big to post)

so in here i got my boss ship… and inside the movie clip… the guns are all seperate movie clips…
now when those are on the stage instead of grouped with the rest of the ship… they shoot fine… but i want to be able to group them so i can move the object as a whole… (and i didnt just use group cuz i wanna add code to it)… so cut the guns out of the ship and paste them on the stage if you want to see them shoot… but i dont know why they wont shoot from within the movie clip… i really need to get this working so any help would be really great… thanks

That was kinda tricky. The problem comes from the fact that when you do this._x from your gun, it returns the _x position in the timeline where you put the clip.

So when you put the clip on the main timeline, you get the right value, but when you put it inside the boss movie clip, you get a relative value. Relative to the position of the boss clip.

Flash handles this with the localToGlobal method. It takes an object containing the coordinates you want to modify, and returns the correct positions.

So what you have to do is change your code a bit:

_root.bosslaser.duplicateMovieClip("badBullet"+_root.enemyShoot, _root.enemyShoot);
mc = _root["badBullet"+_root.enemyShoot];

//You define the point object

//You apply the transformation

//You move the laser to the correct location
mc._x = point.x;
mc._y = point.y;

As I said, tricky…

pom :cowboy:

oh… i see i think… it was taking the x and y of the guns compared to the bounding box of the movie clip… and then applying it to the x and y of the stage huh?

thanks, its workin now… but not quite lining up right… i made it so the lasers constantly shoot so you can see where they line up… its like the y is off…

heres the file… did i put the code in wrong?

That’s right… It seemed to work the first time but not anymore. In that case do it the usual way:

mc._x = this._x+_parent._x-20;
mc._y = this._y+_parent._y;

pom :beam:

thanks man, you are awesome