/ Published in: ActionScript 3
Linebreaks differ between Flash TextField and a plain text file like Notepad. In this example we convert the html linebreaks in Flash to \r\n
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var originalStr:String = "<p>Each<br>word<br>should<br>be<br>on<br>a<br>new<br>line.</p><p>\tThis line should be tabbed.</p><p>But this line shouldn't be tabbed.</p><p><li>Bullet points don't work though</li><li>Bullet points don't work though</li><li>Bullet points don't work though</li></p><p>Paste into Notepad to view the results!</p>"; var textfieldStr:String = unescape(originalStr); var tf:TextField = new TextField(); tf.multiline = true; tf.width = stage.stageWidth; tf.height = stage.stageHeight; addChild(tf); tf.htmlText = textfieldStr; var clipboardForNotepadStr:String = unescape(tf.text.replace(/\r/g, ' ')); System.setClipboard(clipboardForNotepadStr);