addChild preserving unwanted directional changes
I have a player object, with an attached gun object. When I click, the gun fires, creating a projectile at the tip of the gun (known as the barrel in my code). The projectile is then added as a child. Now, my player character is coded to rotate to face the mouse cursor, which is all fine and dandy, but as I rotate, the projectiles I have previously fired rotate with me. Obviously I do not want this behavior. I suspect it has something to do with my poor understanding of the addChild function, and I could really use some clarification. I'm not entirely clueless, but my previous OOP experience has been in 3D engines, and as a result, I'm used to a very different way of thinking. I'm hoping someone here can give me a push in the right direction.
Code:
package
{
import flash.display.MovieClip;
public class Weapon extends MovieClip
{
public var projectile : Projectile;
public function Weapon()
{
}
public function fire():void
{
var P:Projectile;
P = new Projectile;
P.x = barrel.x;
P.y = barrel.y;
addChild(P);
}
}
}