Posted by zupadupa in SWF Studio V3 on Jun 30 2008, 12:55 pm

I would like to copy about 4 files to the c:\db folder of clients using a swf exe.

I have added a text file to layout in the files tab of swf called file.txt and here is the code in the first and only frame of my project
ssCore.init();
ssDefaults.synchronousCommands = true;
ssCore.FileSys.copyFile({from: 'internal://file.txt',to: 'C:\\db\\file.txt'});

the file is set to autoextract and the built exe does nothing. I have not figured out how (even) to trace output to the trace screen yet. I generally suck. BUT I have a neat dashboard almost ready and want to distribute it with a little exe. Any obvious mistakes?

Oh yeah the c:\db folder does exist and there is no existing file called file.txt there.


Posted by mbd in SWF Studio V3 on Jun 30 2008, 02:08 pm

The most common mistake is to not include the plugin that you are trying to use when you build the EXE. Below is some code to check if the command was successful or not. Add this code, republish your SWF and then rebuild your EXE, making sure to enable the debug option in the Output panel of SWF Studio so that ssDebug.trace messages will be sent to the SWF Studio Trace tab. Build your EXE and then view the Trace tab. The easiest way to do this is to press Ctrl+Enter to build and then launch your EXE - the same keys you use in Flash to publish and test your SWF.

ssCore.init();
ssDefaults.synchronousCommands = true;
var return_obj = ssCore.FileSys.copyFile({from: 'internal://file.txt',to: 'C:\\db\\file.txt'});
if (return_obj.success)
{
   ssDebug.trace("The copy was successful");
}
else
{
   ssDebug.trace("ERROR: "+return_obj.Error.description);
}

You can also use the asynchronous method, which is to specify a callback function where data/debug info will be returned.

ssCore.init();
ssDefaults.synchronousCommands = true;
ssCore.FileSys.copyFile({from: 'internal://file.txt',to: 'C:\\db\\file.txt'}, {callback:onCopyFile});

function onCopyFile(return_obj, callback_obj, error_obj)
{
   if (r.success)
   {
      ssDebug.trace("The copy was successful");
   }
   else
   {
      ssDebug.trace("ERROR: "+error_obj.description);
      // You could use return_obj.Error or error_obj - they contain the same properties.
   }


For more information see the following help sections:
Getting Started > Using Plugins
ActionScript API > Overview
ActionScript API > Asynchronous Commands
ActionScript API > Synchronous Commands
ssCore > FileSys (plugin) > copyFile


Posted by zupadupa in SWF Studio V3 on Jul 01 2008, 11:39 am

that kind of detailed help is amazing thank you so much for taking the time to do that. I got your first example to work by publishing my flash project to 8 instead of 9 (using CS3) on a random hunch and it worked. Have a super day and thank you again.
:)