
Posted by: Lois Lindemann on: April 22nd, 2011

Posted in:
Wordpress
Tags for this post:
I’ve been doing some more work on MoreThanMaths.com over the last couple of days. It was high time that I added some content to the Learning Zone. In the process of doing this I learned something. How appropriate.
Anyway, having spent a bit of time grappling with the wonders of combing Flash and WordPress, I thought I’d share what I’ve discovered:
1. Embedding Flash files in a WordPress site
I’ve been doing this for a while (here’s an example) and I’ve found the easiest way is to use a good plugin.
I recommend SwfObj – it’s reliable and really easy to use. I usually add some code to my posts/pages, eg:
[swfobj src="http://www.morethanmaths.com/mtm-content/puzzles/coins-01-triangle-to-square.swf" height="450" width="600"]
Alternatively, I can use the link that the plugin adds to the WordPress dashboard. When writing a post or page, just look for an icon with a little f. It’s sitting next to the other media upload icons. Click it and follow the instructions. It’s easy!
There are two functions from the SwfObj plugin that I don’t use.
- Alignment
I find it easier to align the movie by placing the code inside center tags:
<center>
[swfobj src="http://www.morethanmaths.com/mtm-content/puzzles/coins-01-triangle-to-square.swf" height="450" width="600"]
</center>
- Full screen view
I offer a hyperlink to a full screen version of the file rather than using the built in function (example on this page). This makes it easier for anyone who wants to grab a copy of the movie (eg to embed in a flipchart file for an interactive whiteboard), or who wants to hyperlink straight to it.
Incidentally, if you are going to do this, make sure that your Flash movies don’t have things going on offstage – otherwise they will show up! Many of my movies do have things going on offstage, but before publishing I cover these with a ‘curtain’ – actually a big white rectangle with a hole that shows the stage. Yes, I could deal with this by setting opacity on a webpage, but that won’t help if someone downloads the individual file.
2. Linking one Flash movie to another
Some of my resources aren’t single Flash files, they are too big for that. For example, Measure Island is made from a set of Flash files: one for the introduction, one for the map, one for the flea circus activity etc. They are linked together using Actionscript commands within the Flash files. This command is used to load the flea circus:
_root.loadMovie("ruler_flea_circus.swf");
After trying to get this to work with WordPress, I learned that this doesn’t work quite as I expected. I knew that the loadmovie command was a relative link. I was surprised to learn that it doesn’t point at the folder/directory that contains the Flash movie; instead it defaults to the folder/directory that holds the webpage that the movie is on.
My old site consisted of static html pages, with the relevant Flash files held in the same folders, so that wasn’t a problem. On my WordPress site, it was an issue, because the ‘folder’ containing the page doesn’t exist as such on a database driven site.
I tried lots of things before realising that the solution was easy!
I tried putting an absolute link in my loadmovie commands. The result was crashing Flasherama. Not pretty. Not recommended.
I discovered the base command on Adobe’s page listing Flash OBJECT and EMBED tag attributes
base -. or [base directory] or [URL]. Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files.
I failed at using this in various ways before eventually deciding to try a base command with SwfObj. There is no mention that this is supported on the plugin’s page, but the plugin does use the SWF Object 2.2 library and I was getting desperate…
[swfobj src="http://www.morethanmaths.com/mtm-content/measureisland/mi_intro.swf"</a> height="450" width="600" base="http://www.morethanmaths.com/mtm-content/measureisland/" ]
It worked perfectly! Now when a user clicks on a link in my Flash movie, it looks in my www.morethanmaths.com/mtm-content/measureisland/ folder for the Flash file. No crashing, no gnashing of teeth. You can see the results here.
As I said, I recommend SwfObj – it’s reliable and really easy to use. And it does even more than it says on the tin!