Posted by J_R in SWF Studio V3 on Jan 07 2008, 06:14 am

Hello

I am new to SWF Studio.

I am converting a project to support AS2.0, Flash Player 8 and SWF Studio V3.

I got the swf running in Flash Player 8 with the AS2.0 syntax, so the actionscript part is almost done, except for the filesys2 parts, I can't figure out how I should replace the lines for the Filesys2 plugin to the FileSys syntax.

Here's an example of the older code that I'm trying to convert:

fscommand("Arg", "_level0.desktopdir");  
fscommand("Arg", "Desktop");  // folder id   
fscommand("FileSys2.SpecialFolder", "");


I realized what the code basically does, and then I tried to update the code to:

ssCore.FileSys.specialFolder({folderID:"Desktop"});

But then I started to hesitate because of the syntax originally designed for Filesys.SpecialFolder which reads:

ssCore.FileSys.specialFolder( paramsObject );

Because I can't figure out what parameters should be in the "paramsObject" part.

Anyone, please help. There are pieces of code for saving and loading files using also the filesys2 syntax so I need to find my way to work around this problem for starters.


Posted by mbd in SWF Studio V3 on Jan 07 2008, 09:52 am

The line of code you wrote is correct. The paramsObject can be a generic object that contains properties that match with the input parameters in the docs. In your example "folderID" is an input parameter for the specialFolder method.

The previous fscommand calls would execute asynchronously and data would be returned on a variable that you specified. In V3 the data is returned as a property on an object (the output parameter(s)) that can be returned asynchronously or synchronously. If you want the command to execute asynchronously, the data will be returned to a callback function that you specify. The callback function will receive three objects. The first object will be a copy of the paramsObject you passed, but will also contain the returned data (if applicable) as well as a success property that tells you if the command completed successfully or not.

You can also execute the methods synchronously (only a few are async-only - check the docs). Check the FAQ link in my signature for details about enabling synchronous commands. For a synchronous command data is returned by the V3 command call, so you can use the data in the next line of code.

Check the ActionScript API section of the docs for more info.

Here are some examples:

1. Asynchronous example:

ssCore.FileSys.specialFolder({folderID:'desktop'}, {callback:'onSpecialFolder', scope:this});

function onSpecialFolder(return_obj:Object, callback_obj:Object, error_obj:Object):Void
{
   if (return_obj.success)
   {
      ssDebug.trace('The desktop folder is located: '+return_obj.result);
   }
   else
   {
      ssDebug.trace('ERROR: '+error_obj.description);
   }
}

2. Synchronous example:

var return_obj:Object = ssCore.FileSys.specialFolder({folderID:'desktop'});

if (return_obj.success)
{
   ssDebug.trace('The desktop folder is located: '+return_obj.result);
}
else
{
   ssDebug.trace('ERROR: '+return_obj.Error.description);
}


Both examples trace the outputs to the SWF Studio Trace tab. Make sure to enable debug mode (Output tab) before building your EXE.

For many commands synchronous operation is just easier, but for commands that can take time to execute you might want to make it asynchronous, so that you application does not appear hung.