How can I load .txt ( ISO8859-1 ) text file to TextField() from flex? file is located in same folder with .SWF file
+1
A:
Deleted old post from here, see history for details.
I found the answer for you. Good news: no need for PHP magic! Here's how to do it:
var ldr:URLLoader = new URLLoader();
ldr.dataFormat = URLLoaderDataFormat.BINARY;
ldr.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
ldr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
ldr.addEventListener(Event.COMPLETE, function (event:Event):void {
var bytes:ByteArray = ByteArray(ldr.data);
var text:String = bytes.readMultiByte(bytes.length, "iso-8859-1");
...
});
ldr.load(new URLRequest('http://server.dom/path/to/your-file'));
You need to substitute "iso-8859-1" with the appropriate encoding. You can find the list of valid encodings here.
David Hanak
2009-02-13 12:12:56
sample code would be great (actionscript side only)
Tom
2009-02-16 08:40:15