# Whats the correct syntax?

**URL:** <https://forum.kirupa.com/t/whats-the-correct-syntax/207937>\
**Category:** flash\
**Created:** [November 22, 2006, 10:48pm UTC](https://forum.kirupa.com/t/whats-the-correct-syntax/207937 "2006-11-22T22:48:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimjiminyjimjim](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jimjiminyjimjim](https://forum.kirupa.com/u/jimjiminyjimjim)\
**Post date:** [November 22, 2006, 10:48pm UTC](https://forum.kirupa.com/t/whats-the-correct-syntax/207937/1 "2006-11-22T22:48:36Z")

</div>

I have a function that I want to use for all my menus:

```auto

function button(menuvar){
      trace(menuvar);	
	_root.menuvar.gotoAndPlay("open");
}

```

So if I call the function from a rollover I can send the menu name as a parameter to the function.

```auto

on (rollOver) {
	_root.button("aboutmenu");
}

```

However, its not working. When I trace the variable menuvar it shows as aboutmenu. My movieclip IS called aboutmenu. If I change the target from

\_root.menuvar.gotoAndPlay(“open”);

to

\_root.aboutmenu.gotoAndPlay(“open”);

it does work. So I’m guessing I’ve got the syntax wrong or I need to define the variables differently or something.

Any help would be much appreciated.
