Search code examples
actionscript-3flashairadobedecompiling

Add new function in decompiling *.swf file


I decompiled *.swf file, with JPEXS Free Flash Decompiler 10.0.0

to add new funtion, save strings to text file

Code:

package 
{
   ...
   import flash.filesystem.*;       //  my code

   public class NewSocket extends SecureSocket
   {

      ....

      public function send(param1:String) : void
      {
       //  my code
         var file : File = File.desktopDirector.resolvePath("your_file_name.txt");
         var fs : FileStream = new FileStream();
           fs.open(file, FileMode.WRITE);
           fs.writeUTFBytes(param1);
           fs.close();
       //  my code

         ...
      }     
      ...      
   }
}

I get the message "Not a type string №.."

This string

var file : File = File.desktopDirector.resolvePath("y our_file_name.txt");

Check in flash CS6

import flash.filesystem;

I have not this library

adobe AIR is instaled

how do I solve this problem

Thank you!


Solution

  • Flash CS6 > menu File > Publish Settings.

    Flash CS6 Publish Settings

    At the top right corner there's a Target dropdown list. You should pick an option with AIR int it, otherwise AIR classes won't be available and Flash won't compile the code that uses AIR classes.

    Then, you are to import classes, not packages:

    // Import one class.
    import flash.filesystem.File;
    

    or

    // Import all the package classes.
    import flash.filesystem.*;