google上有个开源库:https://code.google.com/p/csvlib/
基本用法:
[code]
package
{
import com.shortybmc.data.parser.CSV;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
/**
* ...
* @author Amyflash.com
*/
public class Main extends Sprite
{
private var _csv : CSV;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
handleCSV();
}
private function handleCSV():void
{
_csv = new CSV( new URLRequest('example-1.csv') );
_csv.addEventListener ( Event.COMPLETE, completeHandler );
}
private function completeHandler ( event : Event ):void
{
//trace ( _csv.data.join('\r') )
trace(_csv.header[0]+"\n");
trace(_csv.data[0][0]);
// do something ...
}
}
}
[/code]