Posted by JetsFan in SWF Studio V3 on Dec 22 2006, 03:08 pm

Does nothcode v 3.2 allow VBscript using the scripting module? According to the documentation it does, but I can't seem to get it to work. The vbscript seems to load successfully, but the vbscript code doesn't seem to run at all.

I've attached a zip file with the files for your reference....

attachments: test.zip  


Posted by mbd in SWF Studio V3 on Dec 22 2006, 04:41 pm

This isn't explained in the docs but the function that gets called requires one parameter. It is always passed a collection from Flash. In Flash you pass an object with properties on it, and in VBScript you access the properties through the collection. Even if you don't pass any properties on the object, or don't specify an object at all, a collection is being passed to the function.

Had you setup some debug code in Flash you would have seen a script error being displayed in the scriptError output parameter. Granted, the error info returned by the script engine isn't very useful in this case, but it does indicate a runtime error because the error occurs when attempting to call the myTest function. The create and loadCode complete without errors.

If the loadCode errors out it can be because of a syntax error in your code, in which case you should be checking the scriptError parameter to see where that is.

Here's the modified AS file with debugging:

ssCore.init();
ssDefaults.synchronousCommands = true;

var createCyberSourceAPI = ssCore.Script.create({module:'CyberSourceAPI', language:'vbscript'});

if (createCyberSourceAPI.success)
{
   var createCyberSourceAPILoaded = ssCore.Script.loadCode({module:'CyberSourceAPI', path:'startdir://AuthSample.vbs'});

   if (createCyberSourceAPILoaded.success)
   {
      ssDebug.trace(1);

      ssCore.CyberSourceAPI.myTest({param1:'test'}, {callback:'CSReturn', scope:this});
   }
   else
   {
      ssDebug.trace('ERROR('+createCyberSourceAPILoaded.Error.code+'): '+createCyberSourceAPILoaded.Error.description);

      if (createCyberSourceAPILoaded.scriptError)
      {
         ssDebug.trace('scriptError: '+createCyberSourceAPILoaded.scriptError);
      }
   }
}

function CSReturn(return_obj, callback_obj, error_obj)
{
   if (return_obj.success)
   {
      ssDebug.trace(return_obj.result);
   }
   else
   {
      ssDebug.trace('ERROR ('+error_obj.code+'): '+error_obj.description);

      if (return_obj.scriptError)
      {
         ssDebug.trace('scriptError: '+return_obj.scriptError);
      }
   }
}


Here's the VBScript file with an argument in the myTest function and how to access the property being passed.

Function myTest(params)   

   ' params is required here even if no data is being passed.

   trace params.Item("param1")

   myTest = "123"

End Function


Note: I noticed that for running scripts the error description was returning undefined. Although the description in scriptError is typically more useful for syntax and runtime errors, the Error.description property shouldn't be returning undefined. And in this case it would have returned "SCRIPT_ERROR_RUNTIME_ERROR", so your question would probably have been focused on "what is wrong with this script?". This has been fixed for the next release.


Posted by JetsFan in SWF Studio V3 on Jan 02 2007, 12:01 pm

Awesome.... thanks for your help!