0 Replies Latest reply on Nov 8, 2010 2:37 PM by MuskeeterAkshay

    Parsing Text File in Flex and saving it to database



         My Name is Akshay and I am trying to read and parse text files in flex.I am currently beginner in flex and currently having diffculty after reading the file. I also need to save it to the database after reading but if I am able to parse it appropriate it should be good.The code is as below


      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"


         xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">





      public function  readFile(fName:String):void{

      var csvLoader: URLLoader = new URLLoader;

      csvLoader.load(new URLRequest(fName));

      csvLoader.addEventListener(Event.COMPLETE, loaderComplete);





      function loaderComplete( event: Event) : void{

      var fileString: String = event.target.data;





      var noNLStr: String =fileString.split(" ").join("\n");



      txtArea.text = noNLStr;






      <!-- Place non-visual elements (e.g., services, value objects) here -->


      <s:TextArea id="txtArea"


      fontFamily="Tahoma" fontSize="11" fontWeight="bold" width="800" height="500"

      borderColor="#585858" borderAlpha="10"

      paddingLeft="10" color="#00000"  fontStyle="normal" />



      I am able to read the file without a problem into noNLStr variable without a problem. But I am sort of struggling on how to parse it further. The text file looks like below:


      false (indicator whether to read the file or not)

      0,355,841,0,0,0,6 ( multiple comma seperated values)




      The question is how should I proceed after getting noNLStr and then  get the comma seperated values from the text files individually..


      Comments and suggestion would be highly appreciated


      Thanks a lot in advance