# String to MovieClip... is that possible? XML-Related

**URL:** https://forum.kirupa.com/t/string-to-movieclip-is-that-possible-xml-related/264524
**Category:** flash
**Created:** [June 26, 2008, 8:49pm UTC](https://forum.kirupa.com/t/string-to-movieclip-is-that-possible-xml-related/264524 "2008-06-26T20:49:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![XLCowBoy](https://avatars.discourse-cdn.com/v4/letter/x/b2d939/32.png) [@XLCowBoy](https://forum.kirupa.com/u/XLCowBoy)
#### Post date: [June 26, 2008, 8:49pm UTC](https://forum.kirupa.com/t/string-to-movieclip-is-that-possible-xml-related/264524/1 "2008-06-26T20:49:35Z")

</div>

[FONT=Arial]Hi guys,

I’m trying to put together an XML based Flash map. On the right side, is a dynamically loaded XML menu. Now, my problem is that the rollover and rollout effects for the menu doesn’t work.

Basically, I have a movie clip that contains a dynamic textfield and another movieclip (the latter contains a button - I wanted it so that when the user rolls over this button, it plays, and when the user rolls out, it plays an exit “fade”)

This is the actionscript below:

```auto

function countyMenu(menuXML) {
    var itemCount = menuXML.firstChild.nextSibling.nextSibling.childNodes;
    for (var i=0; i<=itemCount.length; i++) {
        if (itemCount*.attributes.type == "county") {
            var countyName = itemCount*.firstChild;
            var linkName = itemCount*.firstChild.nextSibling;
            var menuContainer = mcContainer.attachMovie("menuButton","menuItem"+menuCounter,menuCounter);
            menuContainer._y = menuCounter * menuSpacing;
            menuContainer.trackAsMenu = true;
            menuCounter++;
            menuContainer.countyText.text = countyName.firstChild.nodeValue;
            menuContainer.linkText = linkName.firstChild.nodeValue;
            
            menuContainer.onRelease = function() {
// var menuItem = this._name;
// trace(typeof menuItem);

// mcContainer.menuItem.bCountyBG.gotoAndPlay(2);
                emptyTextContainer = this.linkText;
                trace(emptyTextContainer);
            }
            
            bGoToCounty.onRelease = function() {
                getURL(emptyTextContainer,"_blank");
            }
                
        }
    }
}

```

As you can see, everything works quite well, except for the fact that I can’t reach the individual “path” of each of my dynamically loaded buttons.

I’ve tried using “var menuItem=this.\_name” to retrieve the “path” of my buttons when you rollOver them (which should be something like “mcContainer.menuItem.bCountyBG.gotoAndPlay(2);”), although I need the menuItem to change to whatever this.\_name is.

It doesn’t work because menuItem’s returned value is considered a string, so I can’t use it in my command—\> “mcContainer.menuItem.bCountyBG.gotoAndPlay(2);”

I was wondering if anyone can tell me if it’s possible to convert this string to a movieclip by some sort of function or other means?

Thanks in advance. Please take it easy on me, I’m really fairly new to this.

[/FONT]

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [June 27, 2008, 12:30am UTC](https://forum.kirupa.com/t/string-to-movieclip-is-that-possible-xml-related/264524/2 "2008-06-27T00:30:23Z")

</div>

make a movie clip, name it;

then you can

```auto
_root['mcNameHere'];

```

or

```auto
eval('mcNameHere');

```

Eval will be best/easiest on if you have a path as the string (ie:“someMC.anotherMC.anotherMC”), otherwise use association, the first method.

---

<div class="post-metadata">

### Author: ![XLCowBoy](https://avatars.discourse-cdn.com/v4/letter/x/b2d939/32.png) [@XLCowBoy](https://forum.kirupa.com/u/XLCowBoy)
#### Post date: [June 27, 2008, 7:32pm UTC](https://forum.kirupa.com/t/string-to-movieclip-is-that-possible-xml-related/264524/3 "2008-06-27T19:32:12Z")

</div>

It worked! Cheers Nathan!

(It always surprises me how close Actionscript and Javascript really are - they really are children of ECMA. ).
