# String to Movieclip instance name

**URL:** <https://forum.kirupa.com/t/string-to-movieclip-instance-name/245299>\
**Category:** flash\
**Created:** [November 28, 2007, 11:56am UTC](https://forum.kirupa.com/t/string-to-movieclip-instance-name/245299 "2007-11-28T11:56:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggi](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@eggi](https://forum.kirupa.com/u/eggi)\
**Post date:** [November 28, 2007, 11:56am UTC](https://forum.kirupa.com/t/string-to-movieclip-instance-name/245299/1 "2007-11-28T11:56:52Z")

</div>

Hi,

I have a function to set focus to a movieclip. Something’s wrong, not sure what… I’m blinded by this, and need help!

:ro:

First I’m creating a movieclip container and populating this with movieclips that will make up a menu. Next step is to give focus to the first “tab” initially, and then to have a selecteditem variable that changes as the focus changes…

//Creates an empty movieclip for containing the menu  
menu\_container = this.createEmptyMovieClip(“main\_menu\_mc”, this.getNextHighestDepth());  
menu\_container.\_y = 20;

//Counts through the categorynodes\_array and adds buttons  
//Adds the category name and description to the textfields in “tab”  
for (var i = 0; i\<\_root.categorynodes\_array.length; i++) {  
var m = menu\_container.attachMovie(“tab”, “tab”+i+"\_mc", i);  
m.categoryname\_txt.text = \_root.categorynames\_array\*;  
m.categorydescription\_txt.text = \_root.categorydescriptions\_array\*;  
m.\_x = 30;  
m.\_y = (m.\_height+20)\*i;

function setTabFocus(tab) {  
var tab:Number = tab;  
var tab\_mc:String = “main\_menu\_mc.tab” + tab + “\_mc”;  
trace (tab\_mc);  
if (selectedItem == null) {  
[//Selection.setFocus](https://Selection.setFocus)(main\_menu\_mc.tab0\_mc);  
Selection.setFocus[tab\_mc];  
} else {  
Selection.setFocus(selectedItem);  
}  
}  
setTabFocus(1);  
trace(Selection.getFocus());

Pretty please, help me!  
:sailor:
