Posted by fwhilton in SWF Studio V3 on Oct 22 2008, 10:05 pm

This should be easy. But I can not get my file to save correctly
I can not see what is wrong. It generate error on "writetoFile"

Here is my code for Open and Save

function fOpen():Void{
   var obj = new Object();
   obj.caption = "Open RTEditor File";
   //obj.path = ssGlobals.ssStartDir;
   obj.filter = "RTEditor Files|*.rtefl||";
   obj.style = "list";
   var rF = ssCore.App.showFileOpen(obj);
   
   if (rF.result != ""){
      fName.text = rF.result;
      var r = ssCore.FileSys.readFile({path:fName.text});   
      if (r.success){
         trace(ssDebug.trace("SUCCESS"));
         htmlPane.htmlText = r.result;
         editingPane.text = htmlPane.htmlText;
      }else{
         ssDebug.trace("ERROR: "+r.Error.description);

      }
   } else {
      ssDebug.trace("error");
   }

}

function fSave():Void{
   var obj = new Object();
   obj.caption = "Save RTEditor File";
   //obj.path = ssGlobals.ssStartDir;
   obj.filter = "RTEditor Files|*.rtefl||";
   obj.style = "list";
   var rF = ssCore.App.showFileSave(obj);
   
   if (rF.result != ""){
      fName.text = rF.result;
      var textData = htmlPane.htmlText;
      var r = ssCore.FileSys.writeToFile({path:fName.text, data:textData});
      if (r.result != ""){
         ssDebug.trace("SUCCESS");
      }else{
         ssDebug.trace("ERROR: "+r.Error.description);
      }
   } else {
      ssDebug.trace("pressed cancel");
   }
   
}


I am returning "undefined" on my "r" var when i try to write even though I do have data to save from my textData.
I can open a pre-filled file fine.

BTW... I am trying to save this kind of text...

QUOTE:

shdkjdsh dksjh kj hjg dhjgsd hgd shdsg g sh



See anything wacky?

:)


Posted by northcode in SWF Studio V3 on Oct 22 2008, 10:29 pm

Your test for r.result after the call to FileSys.writeToFile is wrong. FileSys.writeToFile has no output parameters. You should be checking to see if r.success is true or not (like you do for FileSys.readFile) and using that to make your decision instead. Your call is probably working (does the file actually get created/saved?) and you're just telling your use that it failed :)


Posted by fwhilton in SWF Studio V3 on Oct 23 2008, 06:28 am

Tim,

Yes the file does get saved... but the ouput in the file says "undefined"
So, it is creating it just not writing the "textData"...

UPDATE:
hmmmm... the textData varible was returning text, now it isn't.
So, I'll have to fix that

UPDATE 2:
Fixed... i needed to use "TextArea.text" and not "htmlText" to save with.

Thanks

:)