# Function -\> linking

**URL:** <https://forum.kirupa.com/t/function-linking/65633>\
**Category:** Uncategorized\
**Created:** [September 28, 2004, 10:03am UTC](https://forum.kirupa.com/t/function-linking/65633 "2004-09-28T10:03:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amanuo](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@amanuo](https://forum.kirupa.com/u/amanuo)\
**Post date:** [September 28, 2004, 10:03am UTC](https://forum.kirupa.com/t/function-linking/65633/1 "2004-09-28T10:03:44Z")

</div>

i have many buttons, that do practicly the same, except with a different target. Therefore i want to give them a function.  
So far the function is on the \_root. and the buttons ask for it like:

[color=blue]\_root.gonext(“zh”);[/color]

and the function on the root is:

[color=blue]function gonext(mc){[/color]  
[color=blue]targett = “p\_” + mc;[/color]  
[color=blue]targett.gotoAndStop(“whatever”);[/color]  
[color=blue]// plus a lot more[/color]  
[color=blue]}[/color]

So the mc called ‘p\_zh’ should gotoAndStop at “whatever”, but this doesnt work. AS reads the word targett as the target, not as a variable.

How do i let the function link back to the custom mc?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2004, 10:13am UTC](https://forum.kirupa.com/t/function-linking/65633/2 "2004-09-28T10:13:16Z")

</div>

AS reads the targett as a _string_ that has the name of the target, not the target itself. To make the name string a valid movieclip reference, you would need to use eval or array access brackets. ex:

targett = “p\_” + mc; // as name  
targett = _root["p_" + mc]; as a reference to the movieclip named “p\_” + mc in \_root.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2004, 12:32pm UTC](https://forum.kirupa.com/t/function-linking/65633/3 "2004-09-28T12:32:29Z")

</div>

ok  
_root["p_" + mc].gotoAndStop(“over”);  
worked.

no need for giving it a variable name now.

Thanks
