
Copy link to clipboard
Copied
I'm attempting to add line breaks after the code I've included below. I know that I need to add a "\n" after the line of text, but I haven't had any success.
textField.appendText(""+ bldg.S11.Title.text())
textField.appendText("Square Footage: "+ bldg.S11.SF.text())
textField.appendText("Tenant: "+ bldg.S11.Tenant.text())
textField.appendText("Status: "+ bldg.S11.Status.text())
Thank you.
1 Correct answer
You have to have a TextField called "textField" and it needs "wordWrap" and "multiline" properties set to true (as in kglad's post - but there is no "html" property for AS3 TextField class).
Then you can either use html text or normal text:
...// html text
var myText:String = new String();
for(var i:uint = 0; i < bldg.S11.length(); i++){
myText += bldg.S11.Title + "<br />";
myText += "Square Footage: " + bldg.S11.SF + "<br />";
Copy link to clipboard
Copied
if textField is rendering htmlText (i.e. - textField.htmlText = "";), you can use <br> tags, i.e.:
textField.appendText(""+ bldg.S11.Title.text() + '<br>');

Copy link to clipboard
Copied
Adding the + '<br>'); to the end of the line of the text now adds <br> between each line. I have set the text box to render text as html if that makes a difference.
Shops 1 - Unit 101<br>Square Footage: 4,204<br>Tenant: TBD<br>Status: Available<br>
Thank you.
Copy link to clipboard
Copied
you must assign htmlText, not text, to use html in your strings.

Copy link to clipboard
Copied
Heres my code thus far. I made the changes from what I understood you were talking about. This generates an error: 1195: Attempted access of inaccessible method htmlText through a reference with static type flash.text:TextField.
I found this code online which says I need to add somewhere. I'm not sure where.
var myText:String = "<p>This is <b>some</b> content to <i>render</i> as <u>HTML</u> text.</p>";
testField.htmlText = myText;
I'm also not sure what the "myText" would change to in regard to my code.
My Code:
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
xmlLoader.load(new URLRequest("Talega.xml"));
function showXML(e:Event):void {
XML.ignoreWhitespace = true;
var bldg:XML = new XML(e.target.data);
var i:Number;
for (i=0; i < bldg.S11.length(); i++) {
textField.htmlText(""+ bldg.S11.Title.text() + '<br>');
textField.htmlText("Square Footage: "+ bldg.S11.SF.text() + '<br>');
textField.htmlText("Tenant: "+ bldg.S11.Tenant.text() + '<br>');
textField.htmlText("Status: "+ bldg.S11.Status.text() + '<br>');
}
}
Copy link to clipboard
Copied
my error. use:
var myText:String = "<p>This is <b>some</b> content to <i>render</i> as <u>HTML</u> text.</p>"; testField.html = true;
testField.multiline=true;
testField.wordWrap=true;
testField.text = myText;
Copy link to clipboard
Copied
You have to have a TextField called "textField" and it needs "wordWrap" and "multiline" properties set to true (as in kglad's post - but there is no "html" property for AS3 TextField class).
Then you can either use html text or normal text:
// html text
var myText:String = new String();
for(var i:uint = 0; i < bldg.S11.length(); i++){
myText += bldg.S11.Title + "<br />";
myText += "Square Footage: " + bldg.S11.SF + "<br />";
myText += "Tenant: " + bldg.S11.Tenant + "<br />";
myText += "Status: " + bldg.S11.Status + "<br />";
}
textField.htmlText = myText;
// normal text
var myText:String = new String();
for(var i:uint = 0; i < bldg.S11.length(); i++){
myText += bldg.S11.Title + "\n";
myText += "Square Footage: " + bldg.S11.SF + "\n";
myText += "Tenant: " + bldg.S11.Tenant + "\n";
myText += "Status: " + bldg.S11.Status + "\n";
}
textField.text = myText;

Copy link to clipboard
Copied
Success! Thank you.
I have one more question that I think you can answer rather quickly.
I have a button that will load an XML file. I have the button code (below) and then the xmlLoader code shown below that.
What would I need to add and to where to make the event.target load the XML text. There are a series of these in the same fla file so I would have this same line of coding placed under each movie clip.
Button:
s63.addEventListener (MouseEvent.CLICK, onClick);
s63.addEventListener(MouseEvent.ROLL_OVER, mcOver);
s63.addEventListener(MouseEvent.ROLL_OUT, mcOut);
function mcOut( event:MouseEvent):void
{
event.target.alpha = 1;
}
function mcOver( event:MouseEvent):void
{
event.target.alpha = 0.5;
}
function onClick( event:MouseEvent):void
{
event.target.
}
s63.buttonMode = true;
xmlLoader:
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
xmlLoader.load(new URLRequest("Talega.xml"));
function showXML(e:Event):void {
XML.ignoreWhitespace = true;
var bldg:XML = new XML(e.target.data);
var i:Number;
var myText:String = new String();
textField.multiline=true;
textField.wordWrap=true;
textField.text = myText;
for (i=0; i < bldg.S11.length(); i++) {
myText += bldg.S11.Title + "<br />";
myText += "Square Footage: " + bldg.S11.SF + "<br />";
myText += "Tenant: " + bldg.S11.Tenant + "<br />";
myText += "Status: " + bldg.S11.Status + "<br />";
}
textField.htmlText = myText;
}
Copy link to clipboard
Copied
Do you mean something like:
function onClick(e:MouseEvent):void {
loadXML();
}
function loadXML():void {
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
xmlLoader.load(new URLRequest("Talega.xml"));
}
function showXML(e:event){
// process XML
}

