# Calling a function from root to movieclip? IMPORTANT!

**URL:** https://forum.kirupa.com/t/calling-a-function-from-root-to-movieclip-important/301227
**Category:** Uncategorized
**Created:** [December 5, 2009, 2:44pm UTC](https://forum.kirupa.com/t/calling-a-function-from-root-to-movieclip-important/301227 "2009-12-05T14:44:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Huijari](https://avatars.discourse-cdn.com/v4/letter/h/db5fbb/32.png) [@Huijari](https://forum.kirupa.com/u/Huijari)
#### Post date: [December 5, 2009, 2:44pm UTC](https://forum.kirupa.com/t/calling-a-function-from-root-to-movieclip-important/301227/1 "2009-12-05T14:44:21Z")

</div>

So I want call a function from \_root to movieclip:

Here’s the code on main \_root:

[COLOR=#993300]

```auto
 
[COLOR=#993300]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]var[/COLOR] i = [COLOR=#000000]0[/COLOR]; i < bulletArray.[COLOR=#993300]length[/COLOR]; i++[COLOR=#000000])[/COLOR]
    [COLOR=#000000]{[/COLOR]
        [COLOR=#f000f0]*//set a temporary variable that will store the current bullet from the array*[/COLOR]
        [COLOR=#993300]var[/COLOR] temporaryBullet:[COLOR=#993300]MovieClip[/COLOR] = bulletArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR];
        
        [COLOR=#f000f0]*//update temp bullet x & y based on its speed which we calculated during bullet creation*[/COLOR]
        temporaryBullet.[COLOR=#993300]_x[/COLOR] += temporaryBullet.[COLOR=#000000]xSpeed[/COLOR];
        temporaryBullet.[COLOR=#993300]_y[/COLOR] += temporaryBullet.[COLOR=#000000]ySpeed[/COLOR];
        
        [COLOR=#f000f0]*//check for collision*[/COLOR]
        checkEnemyHit[COLOR=#000000]([/COLOR]temporaryBullet[COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]

```

[COLOR=black]Here’s the movieclip’s code:[/COLOR]  
[COLOR=#000000][/COLOR]  
[COLOR=#993300]

```auto
 
[COLOR=#993300]function[/COLOR] checkEnemyHit[COLOR=#000000]([/COLOR]_bullet:[COLOR=#993300]MovieClip[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR]
[COLOR=#000000]{[/COLOR]
        [COLOR=#993300]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]this[/COLOR].[COLOR=#993300]hitTest[/COLOR][COLOR=#000000]([/COLOR]_bullet[COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR]
        [COLOR=#000000]{[/COLOR]
            [COLOR=#f000f0]*//this was hit*[/COLOR]
            [COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"it hits"[/COLOR][COLOR=#000000])[/COLOR];
        [COLOR=#000000]}[/COLOR]
    [COLOR=#000000]}[/COLOR]

```

[COLOR=black]So how to get this working propely? I have spent 3 days to find solution… nothing seems to work…

I have been trying to find any \_global functions and similar but still no work.

Please help, this is very very important for my game! :diss:[/COLOR][/COLOR]  
[/COLOR]
