No More FSCommands?

Previous versions of SWF Studio required that you send commands to SWF Studio using the Flash FSCommand interface. The limitations of the interface made parameter passing difficult, requiring you to spend most of your time figuring out the proper syntax for the commands you wanted to use. SWF Studio's new ActionScript API presents a more advanced object based interface, allowing you to concentrate on what your application is doing rather than how you are telling SWF Studio to do it.

Below is an example of how to use the new ActionScript API to present the user with a Yes/No prompt and call a function once the user has made a selection

ssCore.App.showMsgBox({prompt:'Do you like green eggs and ham?', icon:'QUESTION', buttons:'YESNO'}, {callback:'answer'});

function answer(return_obj,callback_obj,error_obj)
{
    if (return_obj.result == 'YES')
    {
        // The user pressed the Yes button.
    }
    else
    {
        // The user pressed the No button.
    }
}

see also: ssCore Overview.

An alternative method is available called ssCommand. The syntax is similar to the ActionScript API method above, however ssCommand is a lightweight interface and does not provide support for callbacks. Instead ssCommand more closely resembles the old FSCommand interface where you simply specify the Flash variable that will be populated with the response. This forces you to write the code that will wait for the response.

Below is an example using ssCommand to do the same job as the previous example. In this case we are using a Flash watch to monitor the Flash variable we specify and to call a function when a change is detected.

ssCommand('App.showMsgBox','_level0.cc',{prompt:'Do you like green eggs and ham?', icon:'QUESTION', buttons:'YESNO', result:'_level0.mboxAnswer});

function answer(prop,oldval,newval)
{
    if (newval == 'YES')
    {
        // The user pressed the Yes button.
    }
    else
    {
        // The user pressed the No button.
    }
}
_level0.watch('mboxAnswer',answer);

see also: ssCommand syntax and usage, and Flash documentation for watch.

Although ssCommand is always available, we recommend using ssCore when possible to take advantage of the built-in callback handling.