Flash Player Switching on Mac

I have been doing most of my work recently using ActionScript 3 and the Flash Player 8.5 public alpha. However, I recently had to do some Flash Player 8 / ActionScript 2 work, and ran into the issue of switching the Flash Player version installed on my machine. Of course, I could just install / reinstall players as I need them, but that it tedious, and doesn’t lend itself to quickly switching back and forth between player versions (especially during the same session). So, I put together a simple bash script that will quickly switch between player versions (for Firefox and Safari).

First, you need to install Flash Player 8 (I suggest installing the debug version which you can get from the Flash Authoring install / trial). Once it is installed, you can find the plugins in:

/Library/Internet Plug-Ins/

The plugin files are:

Flash Player Enabler.pluginFlash Player.plugin

Inside of this director, create two new directories called 8.0 and 8.5, so that you end up with the following paths:

/Library/Internet Plug-Ins/8.0//Library/Internet Plug-Ins/8.5/

Copy the two Flash Player plugin files into the newly created 8.0 directory.Now, download and install Flash Player 8.5 for Mac. This will overwrite the previous plugins, and now you can copy the

Flash Player Enabler.pluginFlash Player.plugin

files into the 8.5 directory.You probably noticed that the directory that contains the plugin has a space in its name. This normally isn’t a big deal, but it makes accessing the path in a shell script a bit of a pain. So, we are going to make things a little easier, by creating a soft-link to that directory that does not contain a space.Switch to the /Library directory and run the following command:

sudo ln -s Internet\ Plug-Ins/ plugins

Basically, this creates a link called plugins that points to /Library/Internet Plug-Ins. So, we can refer to the Flash Player 8.5 plugin directory like so:


This will make writing our shell script a lot easier.Finally, we need to create a shell script that will allow us to easily switch between plugin versions. Below is a simple bash script that I put together called cfp (change Flash Player). Basically, you call it and pass to it the Flash Player version you want to run, and it will switch to the Player.Here is the script

#!/bin/bashplugin_dir='/Library/plugins'np_dir="$plugin_dir/$1"if [ ! -d $np_dir ]thenecho "$np_dir does not exist."exitficp -rv $np_dir/* $plugin_dir/

You use it like so:To switch to Flash Player 8.0:

sudo cfp 8.0

and to switch to Flash Player 8.5

sudo cfp 8.5

You will be prompted for your password, since you need admin rights to move the plugin files around.Note that the Flash Player version passed in is just the name of the Player directories we created earlier. So you can easily add new player versions by just creating new directories and copying the correct plugin files into that directory.You can confirm that the correct player version is installed by visiting the Flash Player Version Test page. My experience has been that you can switch the players without having to restart the browser, however if you run into any weird issues, I would just try and restart the browser.Now, there are other plugin switchers, but one of the advantages to doing it via bash, is it makes it very easy to automate the plugin switching via a bash or ant script. For example, you could write a script that:

  1. Compiles your ActionScript using MXMLC (AS3) or MTASC (AS2)
  2. Switches the browser to use the correct plugin using this script.
  3. Launches the newly compiled file into the browser.

The next step is to hook up the command line FDB debugger so that you can debug running SWFs on the Mac. Danny Dura and I got this working yesterday, and I will try and post some info on it next week.Post any comments / suggestions / questions in the comments.

6 Responses to Flash Player Switching on Mac

  1. Josh says:

    This is awesome! I’ve just been manually swapping the files in and out using Finder. This is A LOT easier.

  2. Weyert de Boer says:

    Hi Mike! This was exactly where I was looking for yesterday and today. Thanks, you can’t read my mind right?

  3. simon says:

    I wrote the following a while back for use with TextMate as part of my build process. TextMate’s great as it easily allows you to bind scripts to custom commands (and key combinations). However you’d easily be able to adapt it to your set up. It’s using the same principle but allows you to cleanly change all the flash players available for OS X, as well as being able to Uninstall, and optionally restart open browsers (FireFox and Safari).[code]#! /bin/bashFL_VERSION=$1;RESTART_BROWSERS=$2;#Rigged to work with TextMate…FL_PLAYER_ARCHIVE=”$TM_BUNDLE_SUPPORT/FlashPlayers”REQ_FP_PATH=”$FL_PLAYER_ARCHIVE/fp_$FL_VERSION/”UNINSTALL_STR=”uninstall_flash_player”if [ ! -d “$REQ_FP_PATH” ] && [ “$FL_VERSION” != “$UNINSTALL_STR” ]; thenecho “$REQ_FP_PATH cannot be found.”exit 1;fi#if you have osx utils (http://osxutils.sourceforge.net/) installed then use this..PF_A=”/Library/Internet Plug-Ins/Shockwave Flash NP-PPC” #Flash player 5,6PF_B=”/Library/Internet Plug-Ins/flashplayer.xpt” #Flash Player 6,7,8PF_C=”/Library/Internet Plug-Ins/Flash Player Enabler.plugin” #Flash Player 7.0.24 and abovePF_D=”/Library/Internet Plug-Ins/Flash Player.plugin” #Flash Player 7.0.24 and above#Only trash the files that exist (or get bugged by errors).[[ -e “$PF_A” ]] && trash “$PF_A”[[ -e “$PF_B” ]] && trash “$PF_B”[[ -e “$PF_C” ]] && trash “$PF_C”[[ -e “$PF_D” ]] && trash “$PF_D”#Otherwise mv will suffice…#mv -f “/Library/Internet Plug-Ins/Flash Player Enabler.plugin” ~/.Trash#mv -f “/Library/Internet Plug-Ins/Flash Player.plugin” ~/.Trash#mv -f “/Library/Internet Plug-Ins/flashplayer.xpt” ~/.Trash#mv -f “/Library/Internet Plug-Ins/Shockwave Flash NP-PPC” ~/.Trash#Alternatively you could go with rm but read about it first: man rm#Check for unistall only.if [ “$FL_VERSION” == “$UNINSTALL_STR” ]; thenecho “Flash player files moved to Wastebasket.”exit 0;fi#This is destructive if the above fails..cp -R -f “$REQ_FP_PATH” “/Library/Internet Plug-Ins/”if [ “$RESTART_BROWSERS” == “false” ]; thenexit 0;fi# Check if Firefox is running, if so quitFF_OPEN=$(ps -xc|grep -i firefox)[[ $FF_OPEN ]] && osascript -e ‘tell app “FireFox”‘ -e ‘quit’ -e ‘end tell’# Check if Safari is running, if so quit (delay is hacky… but works in most cases)SF_OPEN=$(ps -xc|grep Safari)[[ $SF_OPEN ]] && osascript -e ‘tell app “Safari”‘ -e ‘quit’ -e ‘end tell’ -e ‘delay 2’#Reopen quit broswers[[ $FF_OPEN ]] && open -a FireFox[[ $SF_OPEN ]] && open -a Safari#[[ $SF_OPEN ]] && open -a Safari “http://www.macromedia.com/software/flash/about/”exit 0;#TODO#Grab Safari’s current foremost URL and save for reopening.#SAFARI_URL=””#if [ $SF_OPEN ]; then# SAFARI_URL=`exec osascript

  4. Josh says:

    What about the file “flashplayer.xpt”? It seems that unless this file is swapped as well, the browser will still report the wrong version of the player.A swf will report the correct version of the player, but when I left the .xpt file from the previous version of the player, any JS detection for the player would still report the previous version I had installed, even after restarting the browser.Does the xpt file need to be swapped as well, or was I just seeing things?

  5. mike chambers says:

    >flashplayer.xptGood catch. I didnt test javascript detection. Just copy that file into the appropriate version directory to have the script switch it.mike chambersmesh@adobe.com

  6. david says:

    Really cool! I’m looking for info about encapsulating xmlhttprequest object and javascript oop with event delegate-handling methods. Just I’ve found here (Mike Chambers page).Thanks a lot!vid.