我的AS3没有从导入的XML中读取换行符(/ n或\ n)

时间:2013-03-26 15:45:28

标签: xml actionscript-3

我开始使用数组变量中的字符串创建包含多个图像/链接的横幅,但随着我们的进展,我想将XML添加到混合中,以便我们可以更有效地更新它。

当用户将鼠标悬停在横幅上的图像上时,此文本显示在工具提示中。它在数组变量中运行得很好,但是当从XML中提取它时,它会显示\ n,\ n,/ n,\ r \ n和我能找到的其他所有内容。 </br>给了我一个错误。我尝试过.toString(),找到了ignoreProcessingInstructions属性并尝试将其关闭。根本不值一提。有什么东西真的很简单,我只是没有看到吗?

所以这是有效的: 来自我的AS3数组变量:"Working with Alerts\nand Notifications" //this works fine

来自我的XML:Working with Alerts\nand Notifications //this returns everything inside of the tags, including the \n.

将文字送入tip: tip.tipTitleField.text = titleText[refNum].toString(); //has been tried without .toString() and with .toString() inside of the [], but it always returns the same... correct string, just with the \n plainly visible.

的行

感谢您的任何建议,Chris

1 个答案:

答案 0 :(得分:5)

尝试:

titleText[refNum].replace(/\\n/g,'\n');

titleText[refNum].split("\\n").join("\n");

我有相同的problem来自php的字符串不在Flex中显示新行,也许它有帮助。