...

View Full Version : dynamically format text with actionscript 2.0



ktsixit
12-15-2008, 10:16 AM
Hi all,
I have the following code in my flash, which retrieves text from an xml file.
What I want to do is to apply some styles on the text before it's printed on page


myXML.onLoad = function(success){
if(success){
var root = this.firstChild;
nodes = root.childNodes;
for(var i=0; i<nodes.length; i++) {
scroll_text.text += nodes[i].attributes.name + "\n";
subnodes = nodes[i].childNodes;
scroll_text.text += subnodes[0].firstChild.toString() + "\n\n";
}
} else title_txt.text = "Error loading XML document";
}

right now the code above give this kind of output:
title ( ---> scroll_text.text += nodes[i].attributes.name + "\n"; )
text ( ---> scroll_text.text += subnodes[0].firstChild.toString() + "\n\n"; )

title
text
...

What I want is to make title bold and draw a line between two nodes:
title
text
-------------------------------------------------line------
title
text
-------------------------------------------------line------
...

How am I supposed to do that?

gnomeontherun
12-15-2008, 11:52 AM
You can use HTML to make this happen



myXML.onLoad = function(success){
if(success){
var root = this.firstChild;
nodes = root.childNodes;
for(var i=0; i<nodes.length; i++) {
scroll_text.htmlText += "<strong>" + nodes[i].attributes.name + "</strong>\n";
subnodes = nodes[i].childNodes;
scroll_text.htmlText += subnodes[0].firstChild.toString() + "\n\n";
}
} else title_txt.text = "Error loading XML document";
}

ktsixit
12-15-2008, 02:37 PM
I tried this but it doesn't seem to work

gnomeontherun
12-15-2008, 02:58 PM
You might have to set the field as able to accept HTML output.

Put this near the top of the actionscript (outside of the onLoad)


scroll_text.html=true;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum