# How can i access a MC inside another MC?

**URL:** <https://forum.kirupa.com/t/how-can-i-access-a-mc-inside-another-mc/319947>\
**Category:** flash\
**Created:** [March 9, 2011, 3:59pm UTC](https://forum.kirupa.com/t/how-can-i-access-a-mc-inside-another-mc/319947 "2011-03-09T15:59:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katumi](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@Katumi](https://forum.kirupa.com/u/Katumi)\
**Post date:** [March 9, 2011, 3:59pm UTC](https://forum.kirupa.com/t/how-can-i-access-a-mc-inside-another-mc/319947/1 "2011-03-09T15:59:06Z")

</div>

I’m trying to make an old fashioned 2D sidescroller game similar to the old Mario games, and i’m stuck with a lil problem: I want to add coins that can be collected by the player. I’ve made (with some help) a coin class that unloads the coins when the player touches them:

```php
package 
{
    import flash.display.MovieClip;
    import flash.events.Event;

    public class Coin extends MovieClip
    {
        var character:MovieClip;

        public function Coin()
        {
            this.addEventListener(Event.ENTER_FRAME, update);
        }

        public function update(e:Event):void
        {
            character = MovieClip(root).character;
            if (this.hitTestObject(character))
            {
                this.removeEventListener(Event.ENTER_FRAME, update);
                parent.removeChild(this);
            }
        }
    }
}

```

This works fine when i drag coins onto the stage and walk into them, but the problem is that i want to place every instance into another movieclip called gameLevel, i want gameLevel to hold all of my other movieclips for the sake of scrolling. If i drag the coins into gameLevel i will get the access of undefined property error when i test the game. The code still works though, it unloads the coins, but i’m guessing that error probably is a bad thing 😏  
Does anyone know how i can reference the coins when they are inside of gameLevel? 🙂 Thanks in advance! 🍺
