Synchronous Commands

When an SWF Studio command is called synchronously, data is returned to the caller immediately through a return object and is available for use immediately in the next line of code.

Synchronous commands do not use callbacks. If you specify a callback parameters object the command will be executed as an asynchronous command because the API will assume you want data to be returned to the callback function.

Synchronous calls are not the default call mode in SWF Studio. If you want to enable synchronous calls you can set the default call mode to syncrhonous by setting ssDefaults.synchronousCommands to true or you can use set the sync property of the callback parameters object to true.

Important: If you created your main movie With Flash MX (SWF6) or Flash MX 2004 (SWF7) then you need to upgrade your movie to SWF8 format to use synchronous calls in SWF Studio. You can do this by enabling the "Upgrade the main movie to SWF8 format" option on the Movie Tab. Before enabling this option, make sure you understand the side effects described in Upgrading to SWF8 Format.

Example: using the sync property to enable synchronous calls

var r = ssCore.Win.getPosition({}, {sync:true}); // syncrhonous
ssCore.App.showMsgBox({prompt:r.x + "," + r.y}); // still asynchronous

Example: using ssDefaults.synchronousCommands to enable synchronous calls

ssDefaults.synchronousCommands = true;
var r = ssCore.Win.getPosition({}); // synchronous
ssCore.App.showMsgBox({prompt:r.x + "," + r.y}); // synchronous


If you set the sync property of the callback object to true, the callback function will be ignored, and the call will execute synchronously.

see also: asynchronous commands