Posted by israelb in SWF Studio V3 on Jul 09 2008, 03:16 pm

Hi.....i have a problem....please helpme

this is my code:

var return_obj = ssCore.FileSys.fileExists({path:"startdir://file.txt"});
if(return_obj =='true'){
existe.text="ok"
}

never indicated if is true.


Posted by mbd in SWF Studio V3 on Jul 09 2008, 04:58 pm

Three things:
1. The SWF Studio commands return an object that has properties that contain the data values you are looking for. The documentation contains an example for almost every command, including ssCore.FileSys.fileExists:

var return_obj = ssCore.FileSys.fileExists({path:"startdir://file.txt"});

ssDebug.trace(return_obj.result);


2. Always trace out debugging information when you have troubles. Check return_obj.success to make sure it's true. If it's not, check return_obj.Error.description to see what the problem might be.

See the documentation for more information about the Return Object. There's also a link to this object in the documentation for almost every command.

3. Try tracing out the actual value returned, or read the docs. From the docs:

QUOTE:
Output Parameters:

result - TRUE or FALSE.

The value will NEVER be "true" unless you make the value lowercase. Check for "TRUE".


Posted by israelb in SWF Studio V3 on Jul 09 2008, 07:38 pm

not working.......

this my code:

var return_obj = ssCore.FileSys.fileExists({path:"startdir://file.txt"});

if(return_obj.result=="TRUE") {
existe.text="si"
ssCore.FileSys.deleteFile({path:"startdir://file.txt"});

}else{
existe.text="no"
}

any ideas?


Posted by northcode in SWF Studio V3 on Jul 10 2008, 12:53 am

If the call to fileExists is not returning TRUE or FALSE then you need to find out why the call is failing. You do that by checking first that r.success is true (that one is a boolean, not a string) and then, if r.success is false, you need to check the error description to find out why it failed.


var r = ssCore.FileSys.fileExists({path:"startdir://file.txt"});

if (!r.success)
{
   // the call to ssCore.FileSys.fileExists failed
   ssDebug.trace("error: " + r.Error.description);
}
else
{

   // the call to ssCore.FileSys.fileExists worked,
   // now we have to check r.result to see if the
   // file exists or not

   if (r.result=="TRUE") 
   {
      // the file exists
   }
   else
   {
      // the file does not exist
   }

}
The most likely explanation for why this isn't working is that you haven't enabled the FileSys plugin on the Plugins Tab.


Posted by israelb in SWF Studio V3 on Jul 10 2008, 10:21 am

Hi...thanks for help.....

now in test tab see this message:

error: Synchronous support not enabled. Add "ssDefaults.synchronousCommands = true;" before any V3 API calls, and publish your SWF as version 8 or select the "Upgrade the main movie to SWF8" option in the SWF Studio Movie tab.

help me.....thnks


Posted by mbd in SWF Studio V3 on Jul 10 2008, 10:28 am

Check the FAQ: How do I enable synchronous commands?


Posted by israelb in SWF Studio V3 on Jul 10 2008, 11:41 am

thnks i am try.....


Posted by mbd in SWF Studio V3 on Jul 10 2008, 12:33 pm

Just to modify Tim's example:

// This should go in the first frame of the main timeline of your main movie.
ssCore.init();
ssDefaults.synchronousCommands = true;

// This can go just about anywhere.
var r = ssCore.FileSys.fileExists({path:"startdir://file.txt"});

if (!r.success)
{
   // the call to ssCore.FileSys.fileExists failed
   ssDebug.trace("error: " + r.Error.description);
}
else
{
   // the call to ssCore.FileSys.fileExists worked,
   // now we have to check r.result to see if the
   // file exists or not

   if (r.result=="TRUE") 
   {
      // the file exists
   }
   else
   {
      // the file does not exist
   }
}

If you still get the same message as before, you aren't publishing your SWF for Flash player 8 or higher, which is required for synchronous commands. If you don't have Flash 8 or Flash CS3, then you can have SWF Studio "upgrade" your SWF to version 8 by selecting the checkbox in the Movie tab of SWF Studio.

Or use the command asynchronously by specifying a callback function that will be called when data is returned:

// This should go in the first frame of the main timeline of your main movie.
ssCore.init();
ssDefaults.synchronousCommands = true;

// This can go just about anywhere.
ssCore.FileSys.fileExists({path:"startdir://file.txt"}, {callback:checkIfFileExists});

function checkIfFileExists(return_obj, callback_obj, error_obj)
{
   if (!return_obj.success)
   {
      // the call to ssCore.FileSys.fileExists failed
      ssDebug.trace("error: " + return_obj.Error.description);
   }
   else
   {
      // the call to ssCore.FileSys.fileExists worked,
      // now we have to check r.result to see if the
      // file exists or not

      if (return_obj.result == "TRUE") 
      {
         // the file exists
      }
      else
      {
         // the file does not exist
      }
   }
}