Resolving dynamic movieclip names

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??


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