PDA

View Full Version : .html, perhaps??


mr. sparkle
06-26-2004, 02:35 AM
Situation: a listbox with a list generated from an XML file loads an external text file into a dynamic textbox when the user selects an item. i've got everything worked out except for one minor detail: I cannot get the text field to process HTML. I have the HTML box checked, so I know it's not that. Do I need to include a .html or .htmlText somewhere in my code? Here it is:


var XMLfile = "article_setup.xml";
importXML = new XML();
importXML.varTarget = this;
importXML.ignoreWhite = true;
importXML.onLoad = function (success)
{
if (success)
{
var vt = this.varTarget;
var root = this.firstChild;
vt.articleObj = new Object();
allArticles = root.childNodes;
for(var i=0; i<allArticles.length; i++)
{
article = allArticles[i].childNodes;
vt.articleObj["article" + i] = new Object();
vt.articleObj["article" + i].articleName = article[0].firstChild;
vt.articleObj["article" + i].articlePath = article[1].firstChild;
}
var i;
for (i=0; i<allArticles.length; i++)
{
listBox.addItem(vt.articleObj["article" + i].articleName);
}
select.onPress = function()
{
var myVariable = new LoadVars();
myVariable.onLoad = function(success)
{
if (success)
{
addText(this.article);
}
else trace("Error loading content.");
}
myVariable.load(vt.articleObj["article" + listBox.getSelectedIndex()].articlePath);
}
}
else
{
trace("ERROR PARSING XML");
}
};

function addText(textContent)
{
pbox.text = textContent;

}

importXML.load(XMLfile);



I will be eternally grateful if anyone has any ideas, because I'll finally be able to start loading content into the site, and eventually get it online! Thank you, thank you.

Slowburn
06-26-2004, 05:06 PM
pbox.text = textContent;


to

pbox.htmlText = textContent;

mr. sparkle
06-26-2004, 09:50 PM
Thank You!

mr. sparkle
06-26-2004, 10:44 PM
Alright, one more thing: i've read up on this on various forums, and I see how to do it, but i'm having trouble getting it to work with my particular code.

Can anyone give me a good way to get Flash to not read single line breaks in a text file as a double line break? I know Flash reads Windows line breaks (\r\n) as two line breakx, so I need to find a way to deal with that. Thanks!

Slowburn
06-28-2004, 05:14 PM
I'm not sure I understand your question. you want to read only single line breaks, that are not window line breaks?

annexion
06-28-2004, 05:53 PM
textData.split("\r\n").join("\n");

mr. sparkle
06-28-2004, 05:55 PM
I'm not sure I understand your question. you want to read only single line breaks, that are not window line breaks?

Well yeah, when you break a line in a text file, it shows up as a double line-break in the flash movie. I'm trying to figure out the best way to eliminate that discrepancy, so I can just get single line breaks.

Slowburn
06-28-2004, 05:58 PM
what annexion put down should work.

mr. sparkle
06-28-2004, 06:04 PM
textData.split("\r\n").join("\n");


that did it. Thanksssss a ton !