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.plugin Flash 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.plugin Flash 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:
/Library/plugins/8.5/
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/bash
plugin_dir='/Library/plugins'
np_dir="$plugin_dir/$1"
if [ ! -d $np_dir ]
then
echo "$np_dir does not exist."
exit
fi
cp -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:
- Compiles your ActionScript using MXMLC (AS3) or MTASC (AS2)
- Switches the browser to use the correct plugin using this script.
- 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.






This is awesome! I’ve just been manually swapping the files in and out using Finder. This is A LOT easier.
Josh
6 Jan 06 at 11:44 am
Hi Mike! This was exactly where I was looking for yesterday and today. Thanks, you can’t read my mind right?
Weyert de Boer
7 Jan 06 at 5:47 am
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/bash
FL_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" ]; then
echo "$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,6
PF_B="/Library/Internet Plug-Ins/flashplayer.xpt" #Flash Player 6,7,8
PF_C="/Library/Internet Plug-Ins/Flash Player Enabler.plugin" #Flash Player 7.0.24 and above
PF_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" ]; then
echo "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" ]; then
exit 0;
fi
# Check if Firefox is running, if so quit
FF_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
# tell application "Safari"
#Grab Safari's current foremost URL and save for reopening.
#SAFARI_URL=""
#if [ $SF_OPEN ]; then
# SAFARI_URL=`exec osascript
# -- Find out if Safari has a window open
# if (exists (front window)) then
# -- Get the URL of the page currently displayed in Safari's front window
# set current_url to URL of document of front window
# end if
# end tell
# EOF`
#fi
[/code]
To install the FP 7.0.14 without restarting any open broswers:
[code]changePlayer.sh 7.0.14 false[/code]
To uninstall the flash player:
[code]changePlayer.sh uninstall_flash_player[/code]
To install FP 6.0.49, restarting open browsers:
[code] changePlayer.sh 6.0.49[/code]
simon
7 Jan 06 at 5:16 pm
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?
Josh
9 Jan 06 at 6:48 am
>flashplayer.xpt
Good catch. I didnt test javascript detection. Just copy that file into the appropriate version directory to have the script switch it.
mike chambers
mesh@adobe.com
mike chambers
9 Jan 06 at 9:52 am
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.
david
21 Dec 06 at 8:57 am
Can this be built into a desktop app (or Adobe Air) rather than commandline?
Jay
9 May 08 at 7:24 am
Hey Mike thanks for doing this but I am wondering what I am doing wrong. I put the shell script in my home directory and to run the shell script as you said but I get this message.
>> sudo: cfp: command not found
Matthew Wallace
24 May 08 at 5:08 am
I came up with a solution to do this on Mac OS X Leopard so you can switch between Flash 9 debugger and Flash Beta 10 but you could do it with any other version if you like. It pretty much does the same thing as what Mike suggested in this article but instead of terminal I wrote an Automator workflow that I am calling FlashSwitcher X.
Check it out and let me know what you think. http://flashalisious.com/flashswitcher-x/
Matthew Wallace
3 Jun 08 at 2:00 pm