Skip to content

Play a SWF on the desktop

@swf2es/desktop is an Electron app that plays SWFs in a window, the <swf2es-player> element inside. With Node 22.18 or later, npm runs it with nothing to set up:

Terminal window
npx @swf2es/desktop movie.swf # a local SWF
npx @swf2es/desktop https://example.com/movie.swf # one by its URL
npx @swf2es/desktop app.xml # an AIR application, by its descriptor
npx @swf2es/desktop # the window: File › Open, or drop a SWF or a descriptor on it

The first run downloads Electron’s binary, about 100 MB, once. npx may run a version it cached before rather than a newer one: npx @swf2es/desktop@latest takes the newest. Installed (npm install -g @swf2es/desktop), the command is swf2es-desktop.

Each SWF plays in the sandbox Flash Player gave it. A local SWF goes by its UseNetwork bit: it reads the files beside it and reaches no network, or reaches the network, and sockets you allow, and reads no local file. A SWF opened by its URL plays in Flash’s remote sandbox. ActionScript 3 plays on the builtin.abc and playerglobal the player ships.

Option What it does
--trace Prints what the SWF traces to the terminal: trace() to stdout, warnings and errors to stderr.
--flashvars="a=1&b=2" Gives the SWF FlashVars, as a page’s flashvars parameter: its loaderInfo.parameters, or an AVM1 SWF’s _root variables. Repeated, they are joined.
--param=name=value Gives the SWF one of the parameters a page’s <object> or <embed> gave it, as the element’s attribute of that name: quality, scale, salign, wmode, bgcolor, menu, base or allowNetworking. Repeatable.
--log-network Prints each request, socket and WebSocket of the SWF to stderr: method, URL, status, size and time. The window’s DevTools show none of them, as the main process sends them.
--log-sockets --log-network, and what each socket and WebSocket sends and receives: its size and first 512 bytes, as text or in hex. It prints whatever the SWF sends, a login among it.
--ignore-certificate-errors Does not verify any HTTPS or WSS server’s certificate, for this run.
--ignore-certificate-errors=dev.test,localhost The same for the hosts named alone, on any port.
--ignore-policy-files Lets the SWF read every public host’s data, send it headers and open sockets to it as if its cross-domain policy files allowed it, for this run. This machine and private networks still need their own policy file.
--ignore-policy-files=data.example,localhost The same for the hosts named alone, exactly (not their subdomains), this machine’s and private networks’ too.
--no-http-cache Neither reads nor keeps the HTTP cache, for this run.
--api-version=root Plays the SWF and what it loads at its own SWF version’s API version (its workers at the latest), as Flash did, which hides the classes and members of later players; an AIR application stays at the latest. latest, the default, shows them all; a number plays them at a root of that SWF version’s.
--theme=dark The app’s look for this run: system, light or dark, over View › Theme’s, which stays as it was unless one is chosen from that menu during the run.
--bitmap-resolution=display Keeps vector art the SWF draws into a bitmap at the screen’s resolution for this run, over View › Sharp Bitmaps’, as configure({ bitmapResolution }) does; stage, Flash’s, turns it off.
--software-gl Draws with SwiftShader, on the CPU: where Chromium takes no GPU (a server, Xvfb), or one that gives WebGL but not WebGL 2. Only for SWFs you trust.
--proxy=socks5://host:1080 Sends the SWF’s requests, sockets and WebSockets through a SOCKS5 proxy, for this run (socks5h:// is the same).
--proxy=http://user:pass@host:3128 The same through an HTTP proxy, by a CONNECT tunnel for each connection; either kind takes a username and password.
-- arguments... After an AIR application’s descriptor: the application’s own arguments.

A SWF built for a page reads what its <object> or <embed> gave it, and gets it from the command line:

Terminal window
npx @swf2es/desktop --flashvars="user=guest&lang=en" --param=scale=noScale --param=salign=TL movie.swf
npx @swf2es/desktop "https://example.com/movie.swf?user=guest" # the query is among its parameters

They mean what they mean to the element, case-insensitive in their names as in a page; any other name is left out, as the app says. Write them with =: a value may also follow as an argument of its own, but not one that starts with -, which other switches would read as theirs. base is an http or https URL, or a relative one, resolved against the SWF’s own URL as a page’s against the page’s: for a local SWF, its directory or below, where it reads. The loads it resolves are judged by the SWF’s sandbox as any other. A SWF URL’s query is among its parameters as Flash had it, the FlashVars over it. They are for the SWF the command line names, a second start’s handed to the app already open too, and stay with it as it is reloaded; one opened from the menus, the recent list or a drop gets none. allowScriptAccess, allowFullScreen and allowFullScreenInteractive change nothing here, as the app says: ExternalInterface stays off, and a SWF’s full screen is the window’s, always allowed. An AIR application gets none, as the app says: it has no page.

npx reads the first -- on its command line as the end of its own options, so an application’s arguments need one before the package too: npx -- @swf2es/desktop app.xml -- --server=local (with -y, npx -y -- @swf2es/desktop …). The installed command, swf2es-desktop, takes them as they are.

--ignore-certificate-errors is for a server of your own whose certificate it signed itself. Whoever sits between you and such a host can then read and change what the SWF loads from it, so name the hosts you mean, and leave the switch off otherwise. It is never remembered: the app says so on stderr each time it starts with it.

--ignore-policy-files is for a SWF you trust whose servers no longer serve the policy files Flash asked for. It takes away what those files guarded: the SWF reads, as your machine, whatever your machine reaches of the hosts it covers, and may send it anywhere. No cookies or passwords go with its requests, so your accounts on those sites stay out of its reach, but what is open to your network position is not (a site that trusts your address, say). Bare, it covers public hosts alone: a SWF from the internet still reaches your machine and your local network only where a policy file there grants it, unless you name the host (--ignore-policy-files=localhost, =192.168.1.5). A name matches as written, not its subdomains nor its address. Flash’s other rules stay: a local SWF without UseNetwork reaches no network, sockets still ask you first, and --log-network ends the line of each request the switch let through in allowed by --ignore-policy-files. It covers every SWF the running app opens, one you double-click into it later included; a second start with the switch hands its SWF to the app already open, which keeps what it started with. It is never remembered, and the app says on stderr what it covers each time it starts with it.

Both --ignore-certificate-errors= and --ignore-policy-files= take host names and addresses, matched exactly as a URL writes them, whatever their case, an IPv6 address with or without brackets. An address written another way (127.1, 192.168.010.5) is the address it stands for, a port (dev.test:8443) is taken as every port of the host, a wildcard (*, *.dev.test) matches nothing, and an entry that is not a host alone (https://dev.test, dev.test/x) is left out; the app says each of these on stderr.

--proxy is never remembered either, and the app says on stderr which proxy it uses (its credentials, which come from the command line alone, never). Every connection the main process makes for the SWF goes through it: http and https loads, policy files, sockets and an AIR application’s WebSockets. TLS is the app’s own, over the tunnel, so certificates are checked as without a proxy. The app still resolves a host itself, to tell whether it is on this machine or your network, which a SWF from the internet may not reach without a policy file there, and then asks the proxy for the address it judged; so a host this machine cannot resolve is not reached through the proxy either. A proxy that fails or refuses is a failed load or socket to the SWF, and a line on stderr saying why. An HTTP proxy that allows CONNECT only to port 443, as Squid does by default, refuses plain http and sockets on other ports.

The player draws with WebGL 2. Where Chromium takes no GPU, because there is none or its blocklist refuses the one there is, as on a server, a CI runner or a virtual machine, nothing draws and the app says so on stderr. --software-gl draws with SwiftShader, Chromium’s GPU on the CPU, instead. Chromium calls SwiftShader unsafe for untrusted content, as it compiles code in the GPU process, which on Linux runs outside Chromium’s sandbox, so use it for SWFs you trust.

On a server with no display, run the app under Xvfb, whose only GL Chromium refuses:

Terminal window
xvfb-run -a npx @swf2es/desktop --software-gl --trace movie.swf

Where a Wayland session is about (WAYLAND_DISPLAY, or XDG_SESSION_TYPE=wayland), Electron goes to it rather than to Xvfb: add --ozone-platform=x11.

The app caches the SWF’s http and https GETs as a browser would, by what the server’s Cache-Control, Expires, ETag, Last-Modified and Vary say, up to 512 MB under the system’s cache directory, after Flash’s sandbox and policy files have judged each request, cached or not; each SWF’s origin has a cache of its own. A response with no Cache-Control or Expires of its own is kept for a day at most, by a guess from its Last-Modified, so a SWF updated on its server may play in its old version until then: File › Clear HTTP Cache empties the cache and picks up the new one. File › HTTP Cache turns it off, which the app remembers.

In a checkout of the repository the app runs from its sources:

Terminal window
pnpm build
pnpm --filter @swf2es/desktop start movie.swf

A SWF or an AIR application that sets Stage.displayState takes the window full screen, with no click needed, as in AIR and Flash’s projector; Esc or F11 leaves. F11 is the View menu’s key for it; a SWF or an application that acts on F11 itself, setting Stage.displayState in its keyDown listener, has the key to itself, and one press toggles once.

A SWF gets a Context3D, as in Flash Player and AIR on a desktop: Stage3D content plays with nothing to set up. View › Stage3D turns it off, after which a SWF’s requestContext3D gets Error #3702, “Context3D not available”, and on again; the app remembers the choice and restarts the movie playing.

View › Sharp Bitmaps keeps vector art a SWF draws into a bitmap at the screen’s resolution, so that a map flattened into a bitmap the stage’s size stays as sharp as the stage’s own art in a maximised window (configure({ bitmapResolution }), above). Scripts read Flash’s pixels either way. It is off until chosen; the app remembers the choice and restarts the movie playing, and --bitmap-resolution=display or stage sets it for a single run.

View › Theme makes the app light or dark, or follows the system, the default: its pages, the element’s performance meter and context menu follow, and the title bar and menus where the platform allows. A SWF’s stage keeps its own background colour. The app remembers the choice, and --theme=light or --theme=dark sets one for a single run.

On Linux, a local file a SWF or an AIR application names that is not there as named is found as Windows and macOS find it, ignoring case, so content made there finds its files whatever case it names them in. Where two names in a directory differ only in case, neither is taken.

The desktop app asks before a movie uses your camera or microphone. The dialog names the top-level movie’s source and the requested kind, camera or microphone. A loaded child movie uses that same attribution. Device names may remain blank until consent. The window title shows capture while active; View → Stop Camera and Microphone stops both until the movie is reloaded. Consent is cleared when the movie or page closes. If a movie freezes while stopping capture, the app terminates its renderer to release the devices and offers to reload it. A responsive page awaiting a slow device is allowed to finish opening, then stops the late stream; the title stays marked until closure is confirmed. On macOS, system permission is required as well.

apps/desktop/README.md has the rest: the menus, the sandboxes in full, sockets, files and AIR applications.