看板 Flash 關於我們 聯絡資訊
這是個關於換行的問題。 我想用XML讀取文字並顯示在畫面上 於是我用 notepad++ 來編輯 XML FLASH部分很簡單,就是loadXML之後將資料存入畫面上的textT動態文字方塊中 此文章有排版,請用page down換頁 ==test case 1: 用\n換行== FLASH: textT.text = "text\n"+ xmldata; XML: <?xml version="1.0" encoding="UTF-8"?> <xml> <text>1\n2</text> </xml> 輸出: text 1\n2 結論: 換行失敗 ==test case 2: 加入CDATA == FLASH: textT.text = "text\n"+ xmldata; XML: <?xml version="1.0" encoding="UTF-8"?> <xml> <text><![CDATA[1\n2]]></text> </xml> 輸出: text 1\n2 結論: 換行失敗 ==test case 3: 用ENTER換行 == FLASH: textT.text = "text\n"+ xmldata; XML: <?xml version="1.0" encoding="UTF-8"?> <xml> <text>1 2</text> </xml> 輸出: text 1 2 結論: 換行失敗 (多跳一行) ==test case 4: 用html的BR換行== FLASH: textT.html = true; textT.htmlText = "text\n"+ xmldata; XML: <?xml version="1.0" encoding="UTF-8"?> <xml> <text>1&lt;BR&gt;2</text> </xml> 輸出: text 1 2 結論: 換行成功,但輸入XML的部分是不易閱讀的 且當要輸入整段文章時,必須在同一行內 (很醜的XML) ==test case 4: 用html的BR換行,加上CDATA== FLASH: textT.html = true; textT.htmlText = "text\n"+ xmldata; XML: <?xml version="1.0" encoding="UTF-8"?> <xml> <text><![CDATA[1<BR>2]]></text> </xml> 輸出: text 1 2 結論: 換行成功,但要輸入整段文章時,必須在同一行內 (很醜的XML) == 我的需求:XML可以容易編輯 需求XML: <?xml version="1.0" encoding="UTF-8"?> <xml> <text><![CDATA[ 1 2 ]]></text> </xml> 或 <?xml version="1.0" encoding="UTF-8"?> <xml> <text> 1 2 </text> </xml> 需求結果: 1 2 不曉得有沒有人像我一樣龜毛,研究這種問題 0.0 其實只要讓enter讀不到就可以了,或是讓enter從換兩行變成換一行 -- http://etrex.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.231.67.237 ※ 編輯: etrexetrex 來自: 61.231.67.237 (04/04 16:40) ※ 編輯: etrexetrex 來自: 61.231.67.237 (04/04 16:41) ※ 編輯: etrexetrex 來自: 61.231.67.237 (04/04 16:42)
didila:印象中 CASE 3 是可行的 不過要手動加工一下 04/04 17:08
etrexetrex:教我教我 >////< 04/04 17:09
didila:讀入 FLASH 時候 搜尋 \r\n 取代為 \n 就不會換兩行了 04/04 17:09
didila:不過我是印象派的 手邊目前沒有工具可以測試 04/04 17:10
didila:或是 notepad++ 我記得可以修改..檔頭設定(?) 就不會空一行 04/04 17:11
etrexetrex:解了 ^^ 04/04 17:21
etrexetrex:textT.text = xmldata.split("\r").join(""); 04/04 17:21
etrexetrex:利用上述程式去掉 \r 就好了 04/04 17:21
etrexetrex:這一改 XML就乾淨多了 04/04 17:34