Why does the simple code below output:

---------------------
text.length : 4
textField.length : 4
text : '1

2'
textField.text : '12'
---------------------

and not:
---------------------
textField.text : '1

2'
---------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
        
        <mx:applicationComplete>
                <![CDATA[
                        test()
                ]]>
        </mx:applicationComplete>
        
        <mx:Script>
                <![CDATA[
                        
                        private function test():void{
                                var text:String = "1\r\r2"
                                var textField:TextField = new TextField()
                                textField.htmlText = text
                                
                                trace("text.length : " + text.length) // trace 
--> 4
                                trace("textField.length : " + textField.length) 
// trace --> 4
                                
                                trace("text : '" + text + "'")
                                trace("textField.text : '" + textField.text + 
"'") 
                                
                                textField.autoSize = TextFieldAutoSize.LEFT
                                textField.multiline = true
                                textField.border = true
                                
                                this.rawChildren.addChild(textField)
                        }
                        
                ]]>
        </mx:Script>
        
</mx:Application>

Reply via email to