0 Replies Latest reply on Sep 1, 2012 7:26 AM by benadhon

    Problem loading saved contents back in their places

    benadhon

      I have now gotten the idea of saving multiple components text into one file. But now when I open that file all the text in the file goes into the text of only one component. Here is the code,

       

      <s:Button x="14" y="4" label="Save">

                                  <s:click>

                                      var f:File = File.desktopDirectory;

                                      f.browseForSave("Save As");

                                      f.addEventListener(Event.SELECT, function (event:Event):void {

                                      var stream:FileStream = new FileStream();

                                      stream.open((event.target as File),FileMode.WRITE);

                                      stream.writeUTFBytes(rte.htmlText);

                                      stream.writeUTFBytes(ta.text);

                                      stream.writeUTFBytes(rich.text);

                                      stream.close();

                                      });

                                  </s:click>

                              </s:Button>

       

      <s:Button x="92" y="4" label="Open">

                                  <s:click>

                                      var f:File = File.desktopDirectory;

                                      f.browseForOpen("Select file to open", []);

                                      f.addEventListener(Event.SELECT, function (event:Event):void {

                                      var fs:FileStream = new FileStream();

                                      fs.open(event.target as File, FileMode.READ);

                                      rte.htmlText = fs.readUTFBytes(fs.bytesAvailable);

                                      ta.text = fs.readUTFBytes(fs.bytesAvailable);

                                      fs.close();

                                      });

                                  </s:click>

                              </s:Button>

       

      Some suggestions?