# References to MC's on the Stage through a class?

**URL:** <https://forum.kirupa.com/t/references-to-mcs-on-the-stage-through-a-class/241087>\
**Category:** flash\
**Created:** [October 9, 2007, 10:10pm UTC](https://forum.kirupa.com/t/references-to-mcs-on-the-stage-through-a-class/241087 "2007-10-09T22:10:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrRobot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drrobot/32/3907_2.png) [@DrRobot](https://forum.kirupa.com/u/DrRobot)\
**Post date:** [October 9, 2007, 10:10pm UTC](https://forum.kirupa.com/t/references-to-mcs-on-the-stage-through-a-class/241087/1 "2007-10-09T22:10:33Z")

</div>

alright, so i have a class that is hittesting itself on an object on the stage.

but it keeps returning the object undefined.  
[FONT=Courier New]  
[/FONT]ActionScript Code:  
[LEFT][FONT=Courier New]\</p\>[/FONT]  
[FONT=Courier New]\<p\>package [COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]import[/COLOR] flash.[COLOR=#000080]display[/COLOR]._;\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]import[/COLOR] flash.[COLOR=#000080]events[/COLOR]._;\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000] **class** [/COLOR] Base [COLOR=#0000ff]extends[/COLOR] [COLOR=#0000ff]MovieClip[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]public[/COLOR] [COLOR=#0000ff]static[/COLOR] [COLOR=#000000] **var** [/COLOR] cName:[COLOR=#0000ff]String[/COLOR];\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000] **var** [/COLOR] speed:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]3[/COLOR];\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]private[/COLOR] [COLOR=#000000] **var** [/COLOR] grav:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]3[/COLOR], grounded:[COLOR=#0000ff]Boolean[/COLOR] = [COLOR=#000000] **false** [/COLOR];\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000] **function** [/COLOR] BaseCOLOR=#000000[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“Main Game Base Has Started…”[/COLOR][COLOR=#000000])[/COLOR];\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]stage[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]KeyboardEvent.[COLOR=#000080]KEY\_DOWN[/COLOR], checkKey[COLOR=#000000])[/COLOR];\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]this[/COLOR].[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000080]ENTER\_FRAME[/COLOR], main[COLOR=#000000])[/COLOR];\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000] **function** [/COLOR] checkKeyCOLOR=#000000[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR]event.[COLOR=#000080]keyCode[/COLOR] == [COLOR=#000080]39[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]this[/COLOR].[COLOR=#000080]x[/COLOR]+=speed;\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR]event.[COLOR=#000080]keyCode[/COLOR] == [COLOR=#000080]37[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]this[/COLOR].[COLOR=#000080]x[/COLOR]-=speed;\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000] **function** [/COLOR] mainCOLOR=#000000[/COLOR]:[COLOR=#0000ff]void[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR];\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#0000ff]while[/COLOR] COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> !grounded;\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\> [COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\>[COLOR=#000000]}[/COLOR]\</p\>[/FONT]  
[FONT=Courier New]\<p\>[/FONT][/LEFT]
