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.