# Resolving dynamic movieclip names

**URL:** https://forum.kirupa.com/t/resolving-dynamic-movieclip-names/106551
**Category:** Uncategorized
**Created:** [April 6, 2004, 10:00pm UTC](https://forum.kirupa.com/t/resolving-dynamic-movieclip-names/106551 "2004-04-06T22:00:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![trock](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@trock](https://forum.kirupa.com/u/trock)
#### Post date: [April 6, 2004, 10:00pm UTC](https://forum.kirupa.com/t/resolving-dynamic-movieclip-names/106551/1 "2004-04-06T22:00:20Z")

</div>

Hello Kirupians…

I am trying to dynamically access a function belonging to a dynamically created movieclip instance. I actually got a majority of the code from a tutorial here on Kirupa (thank you very much), but there is one small thing I am trying to do and can’t quite figure out.

I really do not know the best way to describe my problem. I basically have some code which creates the path as a string (the variable “path”), but I cannot figure out how to resolve that string. I have tried using eval, but that is not it. I have tried splitting the path into diff chunks, but that has not worked either.

Basically I need to put a certain number of “.submenu” mclips into my path based on the value of another variable: lvl1cnt. As I mentioned above, the following code creates path correctly, but I can’t seem to figure out how to get Flash to execute the path string as a statement.

Any ideas? Have I given enough info??

```auto

for(var i=0; i<itemcnt; i++){
    path="_root.mmenu";
    for(var j=0;j<lvl1cnt;j++){
        path +=".submenu";
    }
    path+="[\"mitem\"+i].dorollover()";
    //eval doesnt work ;(
    eval(path);
}

```

Thanks,  
tROCK

---

<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: [April 6, 2004, 10:49pm UTC](https://forum.kirupa.com/t/resolving-dynamic-movieclip-names/106551/2 "2004-04-06T22:49:05Z")

</div>

There are several variations you could use… try these two:

```auto
for (var i=0; i<itemcnt; i++) {
	path = "_root.mmenu";
	for (var j=0; j<lvl1cnt; j++) {
		path += ".submenu";
	}
	eval(path)["mitem"+i].dorollover();
}
//
for (var i=0; i<itemcnt; i++) {
	path = _root.mmenu;
	for (var j=0; j<lvl1cnt; j++) {
		path = path.submenu;
	}
	path["mitem"+i].dorollover();
}

```

Check out this thread, it might clear things up for you: [http://www.kirupaforum.com/forums/showthread.php?t=12082#post85182](http://www.kirupaforum.com/forums/showthread.php?t=12082#post85182).

---

<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: [April 7, 2004, 3:41pm UTC](https://forum.kirupa.com/t/resolving-dynamic-movieclip-names/106551/3 "2004-04-07T15:41:05Z")

</div>

FANTASTIC!!

I tried option 2 (just because I liked the way it looked) and it worked to perfection. Thanks alot KODE.

Once again, [Kirupa.com](http://Kirupa.com) to save the day. It is too easy to say this is the best Flash site out there… I think it is one of the best sites (across all genres) out there!

---

<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: [April 7, 2004, 4:02pm UTC](https://forum.kirupa.com/t/resolving-dynamic-movieclip-names/106551/4 "2004-04-07T16:02:09Z")

</div>

No problem, trock. 🙂

…You’re definitely right about that! 😛
