# Breaking line in dynamic text field

**URL:** <https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689>\
**Category:** flash\
**Created:** [April 23, 2006, 6:22pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689 "2006-04-23T18:22:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Poco](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Poco](https://forum.kirupa.com/u/Poco)\
**Post date:** [April 23, 2006, 6:22pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/1 "2006-04-23T18:22:20Z")

</div>

Hello guys,

Please help. I have an XML with a node, let’s say like this:

```auto
<ROW text="This is a line which needs to be broken right here /n to go on from the other line"></ROW>

```

How can I break the line exactly where the /n is after I loaded this XML? Or how to change the XML to get this in the easiest way?  
Thanks a lot for any comments, opinions, help, etc!

Poco

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 23, 2006, 6:26pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/2 "2006-04-23T18:26:42Z")

</div>

maybe its

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 6:30pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/3 "2006-04-23T18:30:12Z")

</div>

or

\*\*EDIT: \*\*Sorry I didn’t read the post above…

---

<div class="post-metadata">

**Author:** ![Poco](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Poco](https://forum.kirupa.com/u/Poco)\
**Post date:** [April 23, 2006, 6:47pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/4 "2006-04-23T18:47:13Z")

</div>

Thanks for replies!  
Of course it is  
, it was a mistake, sorry. But that doesn’t break the line in text field.

Mathew.er, ty si z Ceska?

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 23, 2006, 7:04pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/5 "2006-04-23T19:04:13Z")

</div>

So it does display taht  
normally in text? Look for CDATA here or at google… I think it was something like that.  
[ot]No jasně že jsem. :D[/ot]

---

<div class="post-metadata">

**Author:** ![MichaelxxOA](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@MichaelxxOA](https://forum.kirupa.com/u/MichaelxxOA)\
**Post date:** [April 23, 2006, 7:07pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/6 "2006-04-23T19:07:45Z")

</div>

Do you have it set to multiline? You will not need CDATA (although you may like to read it just for the knowledge). I believe it’s just not set to multiline.

You may also need to escape your escape sequence… changing “  
” to “  
”.

TakeCare.

\_Michael

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [April 23, 2006, 7:13pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/7 "2006-04-23T19:13:08Z")

</div>

Yeah, it should be  
, not /n. 😉

Also, you really shoudln’t make your xml node like that. It would be much better to have the content inside the element, such as…

```auto
<row>This is a line which needs to be broken right here 
 to go on from the other line</row>

```

Or, not quite as good…

```auto
<row text="This is a line which needs to be broken right here 
 to go on from the other line" />

```

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 7:19pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/8 "2006-04-23T19:19:30Z")

</div>

```auto

<row>
<![CDATA[This is a line which needs to be broken right here 
 to go on from the other line]]>
</row>

```

or

```auto

<row>
<![CDATA[This is a line which needs to be broken right here <br> to go on from the other line]]>
</row>

```

or

```auto

<row>
<![CDATA[This is a line which needs to be broken right here \r to go on from the other line]]>
</row>

```

Im just guessing here… I’m not sure if that will work  
Also try puting both quotes in **e.g** ’ and "

---

<div class="post-metadata">

**Author:** ![MichaelxxOA](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@MichaelxxOA](https://forum.kirupa.com/u/MichaelxxOA)\
**Post date:** [April 23, 2006, 7:21pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/9 "2006-04-23T19:21:58Z")

</div>

Another thing is the capitalized element name, this breaks the xml standard which says that all element names as well as attributes need to be in lower-case.

TakeCare  
\_Michael

---

<div class="post-metadata">

**Author:** ![Poco](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Poco](https://forum.kirupa.com/u/Poco)\
**Post date:** [April 23, 2006, 7:35pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/10 "2006-04-23T19:35:48Z")

</div>

Well guys, I may be dumb but I really can’t make it work… none of your solutions works. This is what I set for textfield:

this.maintext\_txt.multiline = true;  
this.maintext\_txt.text = xmlNode.childNodes[0].attributes.description

or

this.maintext\_txt.text = xmlNode.childNodes[0].nodeValue; (if I use it as value)

And the XML:  
\<?xml version=“1.0” encoding=“UTF-8”?\>  
\<ROWS\>  
\<ROW description=“This is a line which needs to be broken right here  
to go on from the other line”\>\</ROW\>  
\</ROWS\>

:q:

EDIT: The XML loads fine, of course.

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [April 23, 2006, 8:09pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/11 "2006-04-23T20:09:13Z")

</div>

> [@Crayon-Inc](#):
>
> ```auto
> 
> <row>
> <![CDATA[This is a line which needs to be broken right here <br> to go on from the other line]]>
> </row>
> 
> ```

Ugh, no! You didn’t close your break… it should be **[font=monospace]\<br /\>[/font]**!

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 9:22pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/12 "2006-04-23T21:22:38Z")

</div>

^  
Sorry… thanks for pointing that out

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 9:30pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/13 "2006-04-23T21:30:57Z")

</div>

How are you loading your xml in flash?

---

<div class="post-metadata">

**Author:** ![MOre](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@MOre](https://forum.kirupa.com/u/MOre)\
**Post date:** [April 23, 2006, 10:03pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/14 "2006-04-23T22:03:18Z")

</div>

try this:

set the following line of code before you assign the xml content to your textfield.

example:

[AS]  
varofyourdynamictexfield.html = true;  
varofyourdynamictexfield.text = …(xml source)  
[/AS]

You must use ‘ **vars** ’ instead of ‘instances’ in order to show HTML tags in your textfield. The xml layout that Crayon-Inc posted earlier is the one to go with.

Hope that solves your problem 😉

---

<div class="post-metadata">

**Author:** ![Poco](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Poco](https://forum.kirupa.com/u/Poco)\
**Post date:** [April 23, 2006, 10:57pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/15 "2006-04-23T22:57:45Z")

</div>

I am loading it with this on root:

```auto

function loadXML(file, goandplay) {
    xml = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function(success) {
        if (success) {
            trace("XML loaded");
            //trace(xml);
            _root.gotoAndPlay(goandplay);
        } else {
            trace("Warning! XML hasn't been loaded!");
        }
    };
    xml.load(file);
}

```

Then this code in external clip:

```auto

function writeToFields(xml){
    var xmlNode:XMLNode = xml.firstChild;
    this.maintext_txt.multiline = true;
     this.maintext_txt.text = xmlNode.childNodes[0].nodeValue;
}
writeToFields(_root.xml);

```

If I do it like this, then from

```auto
<row>
<![CDATA[This is a line which needs to be broken right here <br/> to go on from the other line]]>
</row>

```

I see “null”.

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 11:18pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/16 "2006-04-23T23:18:38Z")

</div>

**EDIT:** I did some research and discovered what to do… exactly like MOre said.

```auto

function writeToFields(xml){
var xmlNode:XMLNode = xml.firstChild;
this.maintext_txt.multiline = true;
this.maintext_txt.html = true;
this.maintext_txt.text = xmlNode.childNodes[0].nodeValue;
}
writeToFields(_root.xml);

```

---

<div class="post-metadata">

**Author:** ![GPP](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@GPP](https://forum.kirupa.com/u/GPP)\
**Post date:** [April 23, 2006, 11:30pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/17 "2006-04-23T23:30:21Z")

</div>

Using this for the xml

```auto

<row>
<![CDATA[This is a line which needs to be broken right here <br /> to go on from the other line]]>
</row>

```

=) Hope that helps

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 24, 2006, 12:17am UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/18 "2006-04-24T00:17:25Z")

</div>

i too am trying to break a string loaded in - dammit this is silly it should be so simple…

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [April 24, 2006, 12:34am UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/19 "2006-04-24T00:34:23Z")

</div>

Hola talk about over complication, use url encoding:

```auto
<?xml version="1.0" encoding="iso-8859-1"?>
<node>Hello my%0Aname is joe!</node>

```

```auto
this.xml = new XML();
this.xml.ignoreWhite = true;
this.xml.load("some.xml");
this.xml.onLoad = mx.utils.Delegate.create(this, function ():Void {
 this.txt.text = unescape(this.xml.firstChild.firstChild.nodeValue);
});

```

:hoser:

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 24, 2006, 1:56pm UTC](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689/20 "2006-04-24T13:56:18Z")

</div>

seems to be about ten posts without mentioning that

```
 ActionScript Code:
 [FONT=Courier New][LEFT][COLOR=#0000ff]this[/COLOR].[COLOR=#000080]maintext_txt[/COLOR].[COLOR=#0000ff]html[/COLOR] = [COLOR=#000000] **true** [/COLOR];

```

[COLOR=#0000ff]this[/COLOR].[COLOR=#000080]maintext\_txt[/COLOR].[COLOR=#0000ff]text[/COLOR] = …  
[/LEFT]  
[/FONT]

should be  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#0000ff]this[/COLOR].[COLOR=#000080]maintext\_txt[/COLOR].[COLOR=#0000ff]html[/COLOR] = [COLOR=#000000] **true** [/COLOR];  
[COLOR=#0000ff]this[/COLOR].[COLOR=#000080]maintext\_txt[/COLOR].[COLOR=#0000ff]htmlText[/COLOR] =…  
[/LEFT]  
[/FONT]

unless im missing something  
:gm:

[Next page](https://forum.kirupa.com/t/breaking-line-in-dynamic-text-field/186689.md?page=2)
