# Passing var to movie control command?

**URL:** <https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790>\
**Category:** Uncategorized\
**Created:** [June 8, 2003, 11:02pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790 "2003-06-08T23:02:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sozugk](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@sozugk](https://forum.kirupa.com/u/sozugk)\
**Post date:** [June 8, 2003, 11:02pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790/1 "2003-06-08T23:02:09Z")

</div>

Hi,

I have question that I believe should be simple. Here it is;

instead of writing for example;

test.gotoAndPlay(2);

I wrote this but does not seem to work;

x = “test”;  
x.gotoAndPlay(2);

Is there a format that I should use to get this to work? Thanks.

---

<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:** [June 8, 2003, 11:31pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790/2 "2003-06-08T23:31:41Z")

</div>

try this…  
dont know if it’ll work but what the hey…

```php

x = eval("_root.test");
x.gotoandPlay(2);

```

i know this works when doing dynamic stuff:

```php

for(i=0;i<5;i++){
_root["movieclip" + i].play();

}

```

hmm =)

---

<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:** [June 8, 2003, 11:33pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790/3 "2003-06-08T23:33:46Z")

</div>

works!! thx… what does eval do anyways?

---

<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:** [June 8, 2003, 11:35pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790/4 "2003-06-08T23:35:48Z")

</div>

eval( ) works when you want to evaluate something as litteral… such as a variable name etc…

since you were doing  
x = “test”; it was assigning it as a string.

if you do the eval(“test”) it goes, ok, this must be a variable name or an object or something other than a string =)

its intended for dyanamic thigns , its most handy =)

---

<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:** [June 8, 2003, 11:37pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790/5 "2003-06-08T23:37:03Z")

</div>

the eval way is deprecated in MX, so you might just wanna stick with the 2nd method :):

```auto
x = "test"
_root[x].gotoAndPlay(2);

```

---

<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:** [June 8, 2003, 11:38pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790/6 "2003-06-08T23:38:07Z")

</div>

or do what ahmed said… =)

even though eval() is still king in other languages… =)

---

<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:** [June 8, 2003, 11:40pm UTC](https://forum.kirupa.com/t/passing-var-to-movie-control-command/22790/7 "2003-06-08T23:40:19Z")

</div>

nice! thanks for the help Raydred and ahmed 🙂
