actionscript 3 - Error #0 when trying to save file on iOS device -


i finished creating ios , android application air ( sdk 18 ) error #0 ( - inconsistable ) when trying save preferences file. code quite straightforward:

private static var _file:file=file.applicationstoragedirectory.resolvepath(configfile); private static function savefile():void{ var filestream:filestream = new filestream();     if(file.applicationstoragedirectory.spaceavailable>1024){             filestream.open(_file, filemode.write);             filestream.writeutfbytes(base64.encrypt(json.stringify(ob),strings.hashsalt));             filestream.close();     }else{         showlowspacealert()     } } 

on android eveything works fine , on ios there no issues 50% of time ... know bug? thanks!

do not try create file object static variable, static objects created during app init time , timing issues appear. problem due code logic.

the correct way is:

private static var _file:file; 

then:

private static function savefile():void {     if(!_file)     {         _file = file.applicationstoragedirectory.resolvepath(configfile);     }     //etc ... } 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -