# Access a function of the parent of an MC?

**URL:** https://forum.kirupa.com/t/access-a-function-of-the-parent-of-an-mc/164837
**Category:** flash
**Created:** [October 5, 2005, 10:41am UTC](https://forum.kirupa.com/t/access-a-function-of-the-parent-of-an-mc/164837 "2005-10-05T10:41:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![CEOofAEP](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@CEOofAEP](https://forum.kirupa.com/u/CEOofAEP)
#### Post date: [October 5, 2005, 10:41am UTC](https://forum.kirupa.com/t/access-a-function-of-the-parent-of-an-mc/164837/1 "2005-10-05T10:41:04Z")

</div>

Hello there 🙂

Well- actually, my problem is a bit more abstract than this thread’s title suggests… here’s the setup:

I have a parent function (called “Game”) with a couple of subfunctions.

There is one subfunction (“Game.prototype.spawnBonus”) that, as the name suggests, spawns a Bonus Item by duplicating a movieclip.

The duplicate movieclip is created on “\_root”-level and has an onEnterFrame attached to it that checks whether a certain stage is met (all this works).

Now the problem is, when the case is met, I need to access a subfunction of “Game” and pass it the MC’s ID to fade out the Bonus Item. Like so:[AS]Game.prototype.fadeBonus = function(number) {  
// just some stuff to fade out the MC with the number  
// passed through the value “number”. This works well,  
// I just need to know how to call this function from  
// within the duplicated MC (see below)  
};

Game.prototype.spawnBonus = function() {  
// - duplicate an MC onto the “\_root”-layer  
// - assign it an id (can later be accessed  
// by the MC through “this.id”)  
// - attach an “onEnterFrame”-loop to it

// All the above works well, but in the  
// “onEnterFrame”-loop, I have this:  
this.\_y += 4;  
if (this.\_y\>=this.end) {  
// … this case is recognized correctly-  
// if I put a “trace” here, it appears.  
// All I need to do is to access  
// “Game.prototype.fadeBonus” from here.  
}  
}[/AS]So… how can I access the function “Game.prototype.fadeBonus” from within the MovieClip that was duplicated by the function “Game.prototype.spawnBonus”?

Your comments and ideas will be welcome 🙂

If all else fails, I’ll just put the “fadeBonus” function outside of the Game function / object… but I wanted to know if it is possible this way 🙂

Thanks in advance!  
~Marcel
