http://www.adobe.com/support/documentation/en/flex/2/releasenotes_flex2_
fds.html
85034 - TextArea uses UNIX-style line endings, which means that text
data containing Windows-style carriage-return line-feed (that is, \r\n)
formatting for new lines contain extra line breaks. You can use
String.replace() with a regular expression to convert the text to
UNIX-style line endings, as the following example shows:
private static const windowsCRLF:RegExp = /\r\n/gm;
...
myTextString = myTextString.replace(windowsCRLF, "\n");
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of shemeshkale
Sent: Tuesday, January 23, 2007 6:57 AM
To: [email protected]
Subject: [flexcoders] extra line coming from an external text
file
hello,
i have made this log watcher for my testing.
it is very basic - loading an external file and putting its
content to a TextArea.
BUT.. for some reason it adds an extra redundant enpty line
after every line - as if the text have two RETURNs (\n) on every line.
what m i doing wrong?
the condenseWhite on the TextArea is not solving this.
any idea?
here is my code(just point it to your own file):
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" initialize="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var myTimer:Timer;
private function init():void{
myTimer = new Timer(1000, 0);
myTimer.addEventListener("timer", loadFile);
myTimer.start();
}
private function loadFile(event:TimerEvent):void{
var request:URLRequest = new
URLRequest("D:/Documents and Settings/someusername/Application
Data/Macromedia/Flash Player/Logs/flashlog.txt");
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE,
completeHandler);
try {
loader.load(request);
} catch (error:Error) {
mx.controls.Alert.show("Unable to load file:
" + error);
}
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
textAR.text = loader.data;
trace(textAR.textHeight);
if(scroll.selected == true)
textAR.verticalScrollPosition = 500;
}
private function stopStart():void{
if(run.selected == true)
myTimer.start();
else if(run.selected == false)
myTimer.stop();
}
]]>
</mx:Script>
<mx:TextArea width="90%" height="50%" wordWrap="false"
id="textAR"
verticalScrollPosition="50" editable="false" />
<mx:CheckBox id="scroll" label="scroll" />
<mx:Button label="clear" click="textAR.text=''" />
<mx:CheckBox id="run" label="run" selected="true"
click="stopStart()" />
</mx:Application>
<http://livedocs.macromedia.com/flex/2/langref/mx/controls/TextArea.html
#condenseWhite>