mardi 28 mars 2017

Adobe flash cs6 Output window closes automatically while executing Filesteam operation in .exe file but it works fine in flash debug mode

I am using adobe flash cs6 for creating a desktop application. In that application iam using flash.filesystem.filestream to save a text file (I dont want to use FileReference because I don't want show the save dialog box ) When I call the new FileStream() in the exported .swf or .exe file, the app stopped running and it closes the window. here is my sample code while executing this line var fileStream : FileStream = new FileStream(); the window closed automatically but this code work fine in Preview mode ( ctrl + Enter) iam using Target: AIR 2.5; Script: ActionScript 3.0 in publish settings.

import flash.filesystem.File;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;    

public class SampleClass {
    public function generateReport (text : String) : void
        var fileMode:String = (FileMode.APPEND);
        var fileStream : FileStream = new FileStream();
        var file:File = File.desktopDirectory.resolvePath("sample.txt"); (file, fileMode);
        fileStream.writeMultiByte (text, File.systemCharset);
        fileStream.close ();



Is there any way to solve this problem ? Thank you very much!


Aucun commentaire:

Enregistrer un commentaire