PDA

View Full Version : xml menu problems ! (createtextfield)


volxn
06-12-2005, 12:42 AM
setup:
i have the XML file "menu.xml"
which contains this code:


<?xml version="1.0"?>
<Menu>
<item>one</item>
<item>two</item>
<item>three</item>
</Menu>


and here's my as-code:


_root.menuxml = new XML();
_root.menuxml.load("menu.xml");
_root.menuxml.ignoreWhite = true;
_root.menuxml.onLoad = function ()
{
for (a = 0; a < _root.menuxml.firstChild.childNodes.length; a++)
{
_root.createTextField("m" + a, _root.getNextHighestDepth(), a*100, 10, 100, 20);
_root.eval("m" + a).type = "dynamic";
_root.eval("m" + a).background = true;
_root.eval("m" + a).backgroundColor = 0xFFFFFF;
_root.eval("m" + a)._x = a * 50;
_root.eval("m" + a)._y = 20;
_root.eval("m" + a)._alpha = 100;
_root.eval("m" + a).html = true;
_root.eval("m" + a)._visible = true;
_root.eval("m" + a).htmlText = _root.menuxml.firstChild.childNodes[a].firstChild;
}
};



the above code is in the frame code of the movieclip "mainmenu"
basically, i want the mainmenu to load the <item>s from the xml and output their contents across the menu at the top.
now, there really isnt any problem reading and loading the XML file, cuz i added
trace(_root.menuxml.firstChild.childNodes[a].firstChild);
within that for () {} loop and it outputted the correct stuff
however, its displaying the textfields which is really getting me, cuz they dont display!!!!
i know it creates the textfields in the correct spots, but when i highlight where i get the text-edit cursor, there's no text!!
here's the website for the thing im talking about: http://volxn.byethost33.com/main.php (the menu is supposed to be the dark bar at the top; if you move your cursor toward its left, youll get the text-editting cursor, but when you move it to the right, you get the mouseover _alpha effect)
if anyone has any solutions, id very much appreciate it!
also, if anyone could somehow make it use dynamically created movieclips instead of textfields, thatd rock too!

thanx so much!!

_xn

Xeef
06-12-2005, 03:20 PM
hi and welcome to As.Org

you are NOT alowed to use "eval" on the LEFT side !!!

something = eval(somethingelse) //ok
eval(somethingelse) = something //BAD

_root.menuxml = new XML();
_root.menuxml.load("menu.xml");
_root.menuxml.ignoreWhite = true;
_root.menuxml.onLoad = function() {
for (a=0; a<_root.menuxml.firstChild.childNodes.length; a++) {
_root.createTextField("m"+a, _root.getNextHighestDepth(), a*100, 10, 100, 20);
_root["m"+a].type = "dynamic";
_root["m"+a].background = true;
_root["m"+a].backgroundColor = 0xFFFFFF;
_root["m"+a]._x = a*50;
_root["m"+a]._y = 20;
_root["m"+a]._alpha = 100;
_root["m"+a].html = true;
_root["m"+a]._visible = true;
_root["m"+a].htmlText = _root.menuxml.firstChild.childNodes[a].firstChild;
}
};

volxn
06-12-2005, 07:26 PM
thanx so much!!!

and actually...you are allowed to use eval as i did...the only thing is, i used _root. in front of it....which ufortunately, it took me an extra day to discover that as my problem (ex. http://volxn.byethost33.com/menu2.html other menu i made this morning, keeping eval() on the left but removing the _root.)

_xn

Xeef
06-13-2005, 12:59 AM
Hmmm

this is out of the MM help

In Flash 5 or later, you cannot use eval() to dynamically set and retrieve the value of a variable or instance name, because you cannot use eval() on the left side of an equation.