Skip to main content
January 29, 2009
Question

Text-Indent with XML/Hml Text bug

  • January 29, 2009
  • 17 replies
  • 3559 views
Hi, this problem has been bugging me and many students here.
I'm importing text from a .xml file, in tat file my text is formatted with HTML and an imported StyleSheet.


The problem is...

Image

The indentation shown here by the red rectangle...
I tried to remove it while using text-indent:0; in my css... didn't work..

I am really clueless righ now.
Thanks for the help.
This topic has been closed for replies.

17 replies

Participant
October 11, 2011

Same problem here - fortunately managed to solve it by setting 2 properties of the XML class:

XML.prettyIndent = 0;

XML.prettyPrinting = false;

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html#prettyIndent

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html#prettyPrinting

I guess this is a problem surfacing through implicit casting of xml objects to strings...

Participant
November 15, 2010

I had the same problem - have dynamic text fields created in Flash, load external CSS to format the text from XML file. The first line in text fields is always indented. I tried all the techniques including xml.ignoreWhitespace set to true and others. Nothing helped. When debugging the xml string in FDT it turns out there are linebreaks "\n" symbols that get inserted into my strings. Well, the only solution I was able to find is to wrap all my html tags in XML into CDATA tags.

Like so:

<header><![CDATA[<h3>Design</h3>]]></header>

<text><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sed velit nibh. Nullam vitae ipsum a ipsum dictum viverra. Vivamus.</p>]]></text>

Watch out for spaces between the <![CDATA[ and <h3> tags and the text itself. Because if you insert one, it will look like an indent and you might spend another couple hours thinking it didn't work

Hope this helps someone else as well.


February 27, 2009
Already tried that, as of now my only guess is that opening a tag result in an indentation.
robdillon
Participating Frequently
February 27, 2009
I'm guessing that the default interpretation of the h1,h2,h3,h4 attributes may be the reason for those items being indented. There's nothing in this code that would cause any of those lines to indent.

There is some weirdness in the way that Flash reads html text. There are many bugs. As a test, you might remove all of the h tags and replace those with p tags and see if the formatting changes. My guess is that it will.
robdillon
Participating Frequently
February 26, 2009
What you are seeing is a paragraph indent. The code that you show from 1/30 shows the setup of two textfields, both named contText. The problem is most likely in the original xml node that contains the text, or it may be in the stylesheet that you are using. If you show those to us, someone may be able to find the problem.
February 26, 2009
Here it is
Participant
February 26, 2009
Hi Xaren,
Did you ever resolve this problem?

I have a similar one. Have loaded text into htmlText property of a textfield and it displays a one character space at the beginning of each line.

Can't seem to find a way to remove it.
February 26, 2009
No I never did... and even after many hours of search I didn't find anthing related to that...
kglad
Community Expert
Community Expert
January 30, 2009
sorry. i'm having a little trouble reading that code and stylesheet.
January 30, 2009
If I knew already what to search for it would kinda help me... you really aren't of any help right now :S
kglad
Community Expert
Community Expert
January 30, 2009
the problem(s) are in getXML() (especially check your parsing) and/or your external xml or text file and possibly your stylesheet.
January 30, 2009
xmlText = loading.getXML("bois");
xmlText.ignoreComments = false;

//Changer le bgHolder par textHolder
contText = new TextField();
contText.embedFonts = true;
contText.selectable = false;
contText.defaultTextFormat = txtSection;
contText.autoSize = TextFieldAutoSize.LEFT;
contText.x = 100;
contText.y = 145;
contText.text = xmlText.section.text();
bgHolder.addChild(contText);

contText = new TextField();
contText.selectable = false;
contText.defaultTextFormat = txtConte;

contText.wordWrap = true;
contText.width = 350;
contText.height = 300;
contText.x = 100;
contText.y = 170;
contText.styleSheet = style;
contText.htmlText = xmlText.contenu.toString();
bgHolder.addChild(contText);


if this can help...