Hey guys…
I’m stuck converting a field to make it accept HTML from an XML file. (I’ve attached a link to the FLA file and attached the XML file. http://www.jeffmorrisonjazz.com/test/middlewindow.fla ) The actionscripting is in the “InternalNav” movie. The code is below.
Essentially, I want the text field that opens up from the nav to accept HTML. In InfoBox > content_txt.
Any help would be greatly appreciated. I keep trying… but I get a “null” result if I put any HTML code in the XML file.
Thanks!
FilmGrrl
// DisplayInfo is used when an item is pressed
// it hides the menu_mc (and the buttons) and shows the
// infobox_mc, assigning the text of the selected button
// to the textbox within.
function DisplayInfo(){
menu_mc._visible = false;
infobox_mc._visible = true;
infobox_mc.content_txt.text = this.location_text;
displaybox_mc._visible = true;
}
// close_btn is in infobox_mc ands restores
// the menu (clearing the info text and hiding itself as well)
infobox_mc.close_btn.onRelease = function(){
menu_mc._visible = true;
infobox_mc._visible = false;
infobox_mc.content_txt.text = "";
displaybox_mc._visible = false;
}
infobox_mc._visible = false; // start the info box hidden
displaybox_mc._visible = false;
// define basic variables for setting up the menu
var item_spacing = 28; // how far menu items are spaced veritcally
var item_count = 0; // counts menu items as they are added from the XML
// CreateMenu creates a menu based on the XML object passed.
// It loops through all the items with a for loop adding clips to the menu_mc
// movieclip on the timeline, defining the appropriate text where needed
function CreateMenu(menu_xml){
// start with the first item in the XML
var items = menu_xml.firstChild.firstChild.childNodes; // menu -> menuitems -> child nodes array
for (var i=0; i<items.length; i++) {
// only continue if the type of this item is a squirrel
if (items*.attributes.type == "PB") {
// create variables for our elements
var species = items*.firstChild; // same as items*.childNodes[0]
var location = items*.childNodes[1]; // second child node
var image = items*.childNodes[2]; // third child node
// Create a menu item movie clip in the menu_mc instance on the main timeline
// for each item element offsetting each additional further down the screen
var item_mc = menu_mc.attachMovie("menu_item","item"+item_count, item_count);
item_mc._y = item_count * item_spacing;
item_count++;
var item_mc1 = displaybox_mc.attachMovie("displayBox","image"+item_count, item_count);
item_count++;
// assign text using nodeValue to get the text
// from the text nodes and CDATA sections
item_mc.species_txt.text = species.firstChild.nodeValue;
item_mc.main_btn.location_text = location.firstChild.nodeValue;
item_mc1.main_btn.image = image.firstChild.nodeValue;
// set the onRelease of the item button to the DisplayInfo function
item_mc.main_btn.onRelease = DisplayInfo;
}
}
}
// CreateMenu2 uses nextSibling and a do-while loop to
// access all the items in the XML. It functions exactly the
// same as CreateMenu, just with a different technique (NOT USED)
function CreateMenu2(menu_xml){
// start with the first item in the XML
var currItem = menu_xml.firstChild.firstChild.firstChild; // menu -> menuitems -> first item
do {
// only continue if the type of this item is a squirrel
if (items*.attributes.type == "PB") {
// create variables for our elements
var species = currItem.firstChild;
var location = species.nextSibling;
// Create a menu item movie clip in the menu_mc instance on the main timeline
// for each item element offsetting each additional further down the screen
var item_mc = menu_mc.attachMovie("menu_item","item"+item_count, item_count);
item_mc._y = item_count * item_spacing;
item_count++;
// assign text using nodeValue to get the text
// from the text nodes and CDATA sections
item_mc.species_txt.text = species.firstChild.nodeValue;
item_mc.main_btn.location_text = location.firstChild.nodeValue;
// set the onRelease of the item button to the DisplayInfo function
item_mc.main_btn.onRelease = DisplayInfo;
}
} while (currItem = currItem.nextSibling); // continue loop if more items exist after current
}
// manage XML
// create new XML object instance, remembering to ignore white space
var PB_xml = new XML();
PB_xml.ignoreWhite = true;
PB_xml.onLoad = parseThisXml;
function parseThisXml(){
content_txt.html=true;
content_txt.htmlText=this.firstChild;
}
// define an onLoad to create our location menu when the XML has successfully loaded.
PB_xml.onLoad = function(success){
if (success) CreateMenu(this);
else trace("Error loading XML file"); // no success? trace error (wont be seen on web)
}
// load the xml file!
PB_xml.load("midNav.xml");