Skip to content

Debug a SWF in the standalone Adobe Flash Player with Visual Studio Code

Josh Tynjala edited this page Aug 2, 2017 · 47 revisions

Prerequisites

Before debugging a SWF file, you will need to download a special version of the Adobe Flash Player that supports debugging. Visit the Adobe Flash Player Debug Downloads page to download the Flash Player projector content debugger for your operating system.

Instructions

  1. Create a new ActionScript project targeting Adobe Flash Player.

  2. In Visual Studio Code, open the command palette by pressing Ctrl+Shift+P (or Command+Shift+P on macOS).

  3. Type launch and select Debug: Open launch.json.

  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",
    			"program": "bin/MyProject.swf"
    		}
    	]
    }
    

    The program field in launch.json should be populated automatically, based on the output compiler option or the name of the main class name specified in asconfig.json.

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

  7. Open Visual Studio Code's Debug pane, 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 same value as the identifier field of the default build task from tasks.json, it will automatically run that task before debugging.

In the following tasks.json, the default build task has a "build-debug" identifier:

{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "2.0.0",
	"tasks": [
		{
			"identifier": "build-debug",	
			"type": "actionscript",
			"debug": true,
			"group": {
				"kind": "build",
				"isDefault": true
			}
		}
	]
}

Specify that identifier as the preLaunchTask in launch.json to run that task automatically when launching in the debugger:

"preLaunchTask": "build-debug"

Launch in a specific version of standalone Adobe Flash Player

If possible, the standalone Adobe Flash Player will open automatically when you debug a SWF program. On Windows and macOS, the debugger will look for an application that is associated with the .swf file extension. On Linux, the debugger will attempt to find a flashplayer or flashplayerdebugger executable by searching the directories registered with the $PATH environment variable.

If the standalone Adobe Flash Player cannot be opened automatically — or if you prefer to test SWF content in a specific version of Adobe Flash Player — you may add the runtimeExecutable field in launch.json to customize which application is launched.

On Windows, set runtimeExecutable to the absolute path of the .exe file:

{
	"type": "swf",
	"request": "launch",
	"name": "Launch SWF",
	"program": "bin/MyProject.swf",
	"runtimeExecutable": "c:\\Downloads\\flashplayer_sa_debug.exe"
}

On macOS, set runtimeExecutable to the absolute path of the .app file:

"runtimeExecutable": "/Applications/Flash Player.app"

On Linux, set runtimeExecutable to the absolute path of the executable file:

"runtimeExecutable": "/home/Downloads/flashplayerdebugger"

Further Reading

Clone this wiki locally