mardi 22 décembre 2015

as3 - How to add a movieclip into the parent's parent?

I have a gun child inside of a movieclip called "player" and "player" is inside another movieclip called "level one".

So inside the gun class, the code spawns a bullet. Which has to spawn in the parent's parent. So the bullet can shoot into the level.

private function fire(m: MouseEvent)
{
    //when bullet fired
    var b = new Bullet;
    MovieClip(MovieClip(parent).parent).addChild(b);
}

However, the bullet never appears in the parent's parent. What could be the issue here?

Aucun commentaire:

Enregistrer un commentaire