If your application started crashing silently when you upgraded your application to ActionScript 3 it might be because of a problem introduced when Adobe made changes to how timers work in ActionScript 3.

The problem occurs when calling certain ssCore commands synchronously from a Timer handler function in an ActionScript 3 project. The solution is just as simple. If you change the ssCore call to be asynchronous the problem should go away.

NOTE: This problem does not occur if you are using ActionScript 1 or 2.

The ssCore commands that cause this are ones that display a message box or a Windows dialog. This isn't something that the Flash Player expects because it's normally not possible when Flash is running in a browser or as a standalone EXE. Flash tells us that it's not happy the only way it can, by crashing.

In the example below we want to display a message box after a period of time and then show which button was pressed to close the message box in a textfield. The messagebox will appear, as expected, but the app will disappear/crash as soon as you click the OK button.

function timerHandler(e:TimerEvent)
{
   var r:Object = ssCore.App.showMsgBox({prompt:"Hello"});
   status_txt.text = r.result;
}

As previously mentioned, the solution is to call your command asynchronously. There are a few ways to do this, but we'll start with the most direct.

Adding a callback to an ssCore command usually makes the command asynchronous, but the commands that display message boxes and dialogs are handled a bit differently. Because of this you need to force the command to be asynchronous by adding sync:false as we've done in the example below. Since we're calling the command asynchronously we also need a callback function to find out which button was pressed.

function timerHandler(e:TimerEvent)
{
   ssCore.App.showMsgBox({prompt:'Hello'}, {sync:false, callback:answer});
}

function answer(r:Object, c:Object, e:Object)
{
   status_txt.text = r.result;
}

The other way to handle this is to bypass the synchronous dialog behaviour completely by setting this flag:

ssDefaults.enableAsyncAsSync = false;
You only need to set this once and you would typically do this at the same time you call ssCore.init() and set ssDefaults.synchronousCommands, at the beginning of your application.

NOTE: Even if you don't set ssDefaults.synchronousCommands to true the message box and dialog commands will still execute synchronously by default, in AS3. We did this to avoid problems with animations freezing in ActionScript 3 after calling an asynchronous command that requires user input.