Skip to content

Debug an Adobe AIR mobile application with Visual Studio Code

Josh Tynjala edited this page Nov 2, 2018 · 65 revisions
  1. Create a new ActionScript project targeting Adobe AIR for mobile.

  2. In Visual Studio Code, open the View menu and select Debug. Alternatively, click the debug icon on the sidebar, or use the Ctrl+Shift+D keyboard shortcut (or Command+Shift+D on macOS).

  3. Click the gear ⚙︎ icon to configure the launch configurations for your workspace.

  4. When prompted to Select Environment, choose SWF.


    If .vscode/launch.json already exists in your workspace, you will not be asked to specify the environment. Instead, the existing file will open. You may click the Add Configuration button to add a new SWF debugging configuration to the existing file. Several default snippets are available, depending on which Adobe Flash runtime you are targeting.


  5. A new editor will open with a launch.json file that looks something like this:

    {
    	// Use IntelliSense to learn about possible SWF debug attributes.
    	// Hover to view descriptions of existing attributes.
    	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    	"version": "0.2.0",
    	"configurations": [
    		{
    			"type": "swf",
    			"request": "launch",
    			"name": "Launch SWF"
    		},
    		{
    			"type": "swf",
    			"request": "attach",
    			"name": "Attach SWF"
    		}
    	]
    }

    We'll be using the Launch SWF debug configuration in a moment.

  6. Specify some extra launch configuration options to simulate a mobile device in the AIR Debug Launcher:

    {
    	"type": "swf",
    	"request": "launch",
    	"name": "Launch SWF",
    	"profile": "mobileDevice",
    	"screensize": "iPhoneRetina",
    	"screenDPI": 326,
    	"versionPlatform": "IOS"
    }

    Setting the profile option to "mobileDevice" is required for all mobile projects. The other three options, screensize, screenDPI and versionPlatform, may be customized to simulate a variety of mobile devices. See launch.json configuration settings for simulating common mobile devices in Adobe AIR for some sample configuration options to use.

  7. Run the build task with Ctrl+Shift+B (or Command+Shift+B on macOS).

  8. Ensure that the Launch SWF configuration is selected is the Debug sidebar, and press the button with the play ▶️ icon to start debugging. Alternatively, use the F5 keyboard shortcut to start debugging.

Build automatically before debugging

Instead of building manually with Ctrl+Shift+B, you can configure launch.json to build your project automatically when you ask it to start debugging.

If you set the preLaunchTask field in launch.json to the name of one of the built-in tasks provided by the ActionScript & MXML extension, it will automatically run that task before debugging. You can find the available tasks when you go to the Terminal menu and choose Run Task....

Warning: If you're compiling debug builds using the Quick Compile & Debug command, DO NOT use preLaunchTask. It will cause your project to build twice before starting the debugger, which won't be very "quick" at all! 😄

In most projects, the preLaunchTask in launch.json should be set to ActionScript: compile debug - asconfig.json:

{
	"type": "swf",
	"request": "launch",
	"name": "Launch SWF",
	"preLaunchTask": {
		"type": "ActionScript",
		"command": "compile debug - asconfig.json"
	}
}

Native Extensions

If your Adobe AIR mobile application requires native extensions, you can specify the extdir field in launch.json to give the AIR Debug Launcher (ADL) access to your unpackaged native extensions:

{
	"type": "swf",
	"request": "launch",
	"name": "Launch SWF",
	"profile": "mobileDevice",
	"screensize": "iPhoneRetina",
	"screenDPI": 326,
	"versionPlatform": "IOS",
	"extdir": "path/to/unpackaged_anes"
}

For details about how to unpackage your ANEs for debugging, search for the documentation that explains how to use the -extdir option at Building Adobe AIR Applications: AIR Debug Launcher (ADL) (adobe.com).

Further Reading

Clone this wiki locally