# Nesting variables problem

**URL:** <https://forum.kirupa.com/t/nesting-variables-problem/197545>\
**Category:** flash\
**Created:** [August 17, 2006, 8:27am UTC](https://forum.kirupa.com/t/nesting-variables-problem/197545 "2006-08-17T08:27:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hexadecimal](https://avatars.discourse-cdn.com/v4/letter/h/9fc348/32.png) [@hexadecimal](https://forum.kirupa.com/u/hexadecimal)\
**Post date:** [August 17, 2006, 8:27am UTC](https://forum.kirupa.com/t/nesting-variables-problem/197545/1 "2006-08-17T08:27:20Z")

</div>

[COLOR=Red]Hi guys I have this function that won´t work as I need it to, I hope someone can help me out. I need to nest two things and basically this is what I want to achieve[/COLOR] \_root[“content\_mc.inside\_mc.item”+currchap+"\_mc"].loadMovie(“chapters/”+currchap+".swf");

[COLOR=Red]Anyway, below, you can see the function and my attempts to solve this, any ideas?[/COLOR]  
\_root.content\_mc.forward\_btn.onRelease = function() {  
var currchap = \_root.chap+1;  
var currClip:String = “\_root.content\_mc.inside\_mc.item”+currchap+"\_mc";  
[COLOR=Red]//This works as a path, currClip[/COLOR]  
endX = getProperty(currClip, \_x)_-1;  
endY = getProperty(currClip, \_y)_-1;

[COLOR=Red] //this works but item2 needs to be dynamic also[/COLOR]  
\_root.content\_mc.inside\_mc.item2\_mc.loadMovie(“chapters/”+currchap+".swf");

```
    [COLOR=Red]//So I tried this, and it doesn´t work, but I don´t get any actionscript errors [/COLOR]
    _root["content_mc.inside_mc.item"+currchap+"_mc"].loadMovie("chapters/2.swf");
    
    [COLOR=Red]//So I traced it and it is Undefined[/COLOR]
    trace(_root["content_mc.inside_mc.item"+currchap+"_mc"]);
    
   [COLOR=Red] //This is what i want to achieve[/COLOR] _root["content_mc.inside_mc.item"+currchap+"_mc"].loadMovie("chapters/"+currchap+".swf");
    
    [COLOR=Red]//I also tried to make the movieclip´s path to a variable so that i can target it like the following:[/COLOR]
    var tempVar:String = "_root.content_mc.inside_mc.item"+currchap+"_mc";
    var clipVar:MovieClip = tempVar;
    trace(clipVar);
    clipVar.loadMovie("chapters/"+currchap+".swf");

```

}  
[COLOR=Red]I get an error, since tempvar is a string and clipvar is a movieClip i get a type mismatch? is there any possibility to fix this[/COLOR]
