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

[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:


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]

make a movie clip, name it;

then you can

_root['mcNameHere'];

or

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.

It worked! Cheers Nathan!

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