开发者

How to use line breaks in Flex with PHP string

This is the MXML I have

<mx:Text id="name" styleName="textStyle" maxWidth="400"></mx:Text>

Then in the same file I have :

<mx:Script>
    <![CDATA[

    private function init():void
    {
       name.text = data.string;
    }

    ]]>
</mx:Script>

data.string comes from the DB and it contains this :

"This is a string \n with two lines."

I also tried this :

"This is a string &#13; with two lines."

None of them create a new line in flex they are both rendered to the screen as \n and &#13;.

How can I create a new line with a string that is coming from the开发者_StackOverflow database?

If I type \n like this in the code it works :

name.text = "test \n test"; 

but if I do name.text=data.string; it doesn't even though data.string has the exact same value.


I think that you can find something you want in this site.

http://www.switchonthecode.com/tutorials/flex-php-tutorial-transmitting-data-using-json


If I run this on the string coming from the DB it works:

string.split("\\n").join("\n");


Or you can use String.replace:

string.replace(/\\n/g,'\n')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜