繁体   English   中英

Adobe AIR-FileStream可以在本地保存,但不会触发任何事件

[英]Adobe AIR - FileStream works to save locally but does not fire any event

我在应用程序存储本地写入utf文件。 该文件已正确写入,但是不会触发任何事件。

public static function saveFileToStorage            (path:String, file:*):Boolean { // This savea a ByteArray as a binary or a string as an UTF8 somewhere...
    var f                               :File = File.applicationStorageDirectory.resolvePath(path); 
    // create a file stream
    var fs:FileStream                   = new FileStream();
    fs.addEventListener                 (Event.COMPLETE, onFileSaved); 
    fs.addEventListener                 (Event.CLOSE, onFileSaved); 
    fs.addEventListener                 (IOErrorEvent.IO_ERROR, onFileSavedError); 
    fs.addEventListener                 (OutputProgressEvent.OUTPUT_PROGRESS, onFileSavedOutputProgress); 
    fs.addEventListener                 (ProgressEvent.PROGRESS, onFileSavedProgress); 
    // open the stream for writting
    fs.open                         (f, FileMode.WRITE);
    // write the string data down to the file
    if (file is String)                     fs.writeUTFBytes(file);
    else                                fs.writeBytes(file);
    return                          true;
}
public static function onFileSaved          (e:Event):void {
    Debug.debug                     (_debugPrefix, "File saved successfully.\n"+e);
}
public static function onFileSavedOutputProgress    (e:Event):void {
    Debug.debug                     (_debugPrefix, "File save output progress...\n"+e);
}
public static function onFileSavedProgress          (e:Event):void {
    Debug.debug                     (_debugPrefix, "File save progress...\n"+e);
}
public static function onFileSavedError         (e:Event):void {
    Debug.error                     (_debugPrefix, "File save error.\n"+e);
}

文件已正确保存,但是未触发任何事件……什么都没有……纳达……这变得神秘起来了……有任何暗示吗?

谢谢

您明确要求的FileStream不触发任何事件,这样你为什么希望任何被解雇? 出于这个原因,这个问题没有任何意义。

FileSteam.open = syncronous and no event fired.
FileStream opanASync = asynchronous and events fired.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM