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

Chr*_*sey 2 xml actionscript-3

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

当用户将鼠标悬停在横幅上的图像上时,此文本将显示在工具提示中.它在数组变量中运行得很好,但是当从XML中提取时,它会显示\n,\n,/ n,\ r \n和我可以找到的其他所有内容.A </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.

谢谢你的任何建议,克里斯

Bar*_*klı 5

试试:

titleText[refNum].replace(/\\n/g,'\n');
Run Code Online (Sandbox Code Playgroud)

要么

titleText[refNum].split("\\n").join("\n");
Run Code Online (Sandbox Code Playgroud)

我有同样的问题,来自PHP的字符串不在Flex中显示新行,也许它有帮助.