jsCommand

jsCommand is a method for executing SWF Studio commands from within a JScript module that is loaded into a SWF Studio application.


Availability:

First available in version 3.0 build 2039.


Usage:

returnObject = jsCommand(commandString,parametersObject)

returnObject - Object - Data is returned immediately to this object. The properties of this object correspond to the Output Parameters of the command specified in the commandString.


Parameters:

commandString - String - The command to execute. See the Plugins and ssCore sections for listings of available commands.

parametersObject - Object - An object containing properties that correspond to the Input Parameters of the command specified in the commandString.


Notes:

None.


Examples:

Example 1:
In this example we will minimize the window.

jsCommand("Win.minimize",{});

Example 2:
Here we will prompt the user with a message box and send a message to the SWF Studio trace window depending on the response chosen.

var return_obj = jsCommand("App.showMsgBox",{prompt:"Do you like green eggs and ham?",buttons:"YESNO"});
if (return_obj.result == "YES")
{
    trace("You like green eggs and ham!");
}
else if (return_obj.result == "NO")
{
    trace("You're probably with the majority!");
}

Example 3:
This example demonstrates a function that will encrypt and then compress a file. If the process fails at any point we return false, which stops further processing of the function and returns the value of false where the function call was made. In the case where this function is called from ActionScript, the value of the out parameter "result" will be populated with false. If the function completes without errors the value of true will be returned.

function packageFile()
{
    var enc_obj = jsCommand("Crypto.encryptFile",{source:"startdir://file.doc",destination:"startdir://file.enc"});

    if (!enc_obj.success)
    {
        alert("Error encrypting file:"+enc_obj.Error.description);
        return false;
    }

    var comp_obj = jsCommand("Compress.deflateFile",{source:enc_obj.source,destination:enc_obj.destination,key:"1234567890"});

    if (!comp_obj.success)
    {
        alert("Error compressing file:"+comp_obj.Error.description);
        return false;
    }

    return true;
}