Link to home
Start Free TrialLog in
Avatar of cacklebunny
cacklebunny

asked on

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";
 
parseData("mySectionName");
 
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"] = mySubNode.attributes.id;
		tempMovie = this["menuName"];
 
		// assign node data
		this["menuHeader"] = mySubNode.childNodes[0].firstChild.nodeValue;
		tempText = this["menuHeader"];
 
		_level0.flyouts.tempMovie.menuHeader = tempText;
}
 
//**** SAMPLE XML FILE ****//
<xml>
  <root>
	<menuitem id="mySectionName">
		<menuHeader>Testing</menuHeader>
	</menuitem>
	
   </root>
</xml>

Open in new window

Avatar of blue-genie
blue-genie
Flag of South Africa image

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.
Avatar of cacklebunny
cacklebunny

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Designbyonyx
Designbyonyx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial