Search code examples
apache-flexnewlineflex4.5

Programmatically adding new line in mx:TextArea


I have a flex 4.5 application. I want to add new line in an mx:TextArea when certain event occurs. I have been searching for the proper way to add a OS independent line ending. I found out that the File class has lineEnding property. However the documentation states that this class is not exposed when running inside a browser (which is my case).

I have searched, but I couldn't find any other class, which can provide this information. Actually I am not sure if the TextArea line ending is OS dependent or not.

So actually I have two questions: Are TextArea line endings OS dependent or not? And if so, how can I get the proper line ending in flex?


Solution

  • You can use String.fromCharCode(13). This will return a line ending. This is the equivalent of PHP's chr() method.

    Example:

    var address_str:String = "dog" + String.fromCharCode(64) + "house.net";
    trace(address_str); // output: [email protected]