Trying to pass movieclip name to function

I can't seem to get my script to recognize a value of a movieclip I"m passing to a function.

I'm using Actionscript 2.0.

See code snippet for the function.

This doesn't work.  However, if I hardcode the actual values and just do:

_level1.flyouts.TheNameOfMyMovieClip.TheNameOfMyTextField = "foobar";

then the textfield will correctly read, "foobar."

Can you tell me what I'm doing wrong?
import com.xfactorstudio.xml.xpath.*;
var my_xml = new XML();
my_xml.scope = this;
my_xml.ignoreWhite = true;
XMLPathFile = "text.xml";
function parseData(thesection) {
	var myXMLNode = XPath.selectNodes(my_xml, "//menuitem[@id='" + thesection + "']");
	//get text from XML file, line by line
	for (var i = 0; i<myXMLNode.length; i++) {
		var tempMovie:MovieClip;
		var tempText:TextField;
	                     mySubNode = myXMLNode[i];		
                                          this["menuName"] =;
		tempMovie = this["menuName"];
		// assign node data
		this["menuHeader"] = mySubNode.childNodes[0].firstChild.nodeValue;
		tempText = this["menuHeader"];
		_level0.flyouts.tempMovie.menuHeader = tempText;
//**** SAMPLE XML FILE ****//
	<menuitem id="mySectionName">

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hi, i'm not familiar with XPath that you're using, but i don't think thats your problem.
var myXMLNode  traces undefined.
so you need to fix that first.
cacklebunnyAuthor Commented:
myXMLNode traces fine for me.  In fact, if I trace tempMovie, it returns what I'd want, but I'm not sure if it's tracing the value as a string or a movieclip.

I think the crux of my problem is that I'm trying to pass a string name to the function and I want it to reference a movieclip of the same name.  For some reason it won't recognize it as a movieclip type event though I've declared it as such.
You are almost there... I can't really test at the moment, but you should be storing your temp variables as Strings and using the following syntax:

Please note, that if you trace a movieclip, you should get a full path :

trace(this); // Called from within movie2

Output: _level0.movie1.movie2

The reason you do not get an error is because your XML data has not been datatyped... so when you assign a variable of type Movieclip to this untyped data, flash doesn't know that you have made an invalid assignment.
var tempMovie:String;
var tempText:String;
// Assuming your textfield variable name is menuHeader
_level0.flyouts[tempMovie].menuHeader = tempText;
// The above could also be written:
_level0["flyouts"][tempMovie]["menuHeader"] = tempText;
// Notice how tempMovie has no quotes around it as we want to insert
// the String value of tempMovie.

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.