# Issue referencing a classes stage name: bullet code

**URL:** <https://forum.kirupa.com/t/issue-referencing-a-classes-stage-name-bullet-code/305776>\
**Category:** programming\
**Created:** [March 3, 2010, 12:41pm UTC](https://forum.kirupa.com/t/issue-referencing-a-classes-stage-name-bullet-code/305776 "2010-03-03T12:41:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LaSquiggle](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@LaSquiggle](https://forum.kirupa.com/u/LaSquiggle)\
**Post date:** [March 3, 2010, 12:41pm UTC](https://forum.kirupa.com/t/issue-referencing-a-classes-stage-name-bullet-code/305776/1 "2010-03-03T12:41:50Z")

</div>

Hi all,

Have had a heck of a time trying to figure this one out;

What I want to do is reference a classes stage name.

I have 2 classes in question,

A gun class, and a bullet class.

The gun class gets loaded via a addchild method wherever the player clicks - it has a movieclip that goes with it, and within that movieclip i have a hitbox which I’d like to reference from within it’s own class.

EG what I WANT to do is refrence basically, “this.hitbox” somehow in reference to gun.hitbox, but obviously this won’t work as the class doesn’t realise that “this” is a movieclip per say with a movieclip inside it.

Is there a way of doing this using localtoGlobal? I’m stumped.

I’ve got this:

var hitboxpoint:Point = this.localToGlobal(new Point(this.x, this.x));  
newBullet.x = hitboxpoint.x; //creates a new bullet with x from guns hitbox  
newBullet.y = hitboxpoint.y; // “” y hitbox

But obviously this just makes it spawn from the gun itself - I need to somehow get it to figure out there is a movieclip inside “this” named hitbox which I then want to use as the x/y.

I’m trying to get my bullets to spawn from the end of the gun when it shoots - but can’t reference the hitbox - I can do it fine if I have the gun already on the stage and then just use its instance name - but problem is I want to be able to dynamically do it after the classes movieclip is created via an addchild.

Thanks for your help!
