Displaying Flash in a Joomla article

posted in: Flash, Joomla | 0

You’d have thought that embedding Flash in a Joomla article would be a simple process, and in some cases it is, however as soon as the Flash uses external assets like XML, images or other swfs etc, you quickly run into problems.

There are loads of Flash plugins for Joomla. They mainly allow Flash banners etc to be easily inserted into modules. There are also some plugins which allow Flash content to be displayed in an article.

However if the Flash file uses external content with is not referenced by absolute URL’s, the Flash will not be able to retrieve its external content.
The usual symptoms of this are, that the main Flash file loads and sometimes the background or intro is displayed but nothing else seems to work.

This is caused because the article pages all served by index.php which is at the root level of the site.



However the Flash file and its other assets are unlikely to be in the root level of the website.
If the files were uploaded using the media manager, they are likely to be somewhere inside the “images” folder, most probably in their own subfolder.

So the absolute path to the Flash file could be


and its data could be


When “theFlash.swf” is embedded into an article using the path
/images/myflash/theFlash.swf it’s loaded into www.mysite.com/index.php

Flash takes the location of the HTML page in which the SWF is loaded to be the root for all future calls for Flash assets.

So theFlash.swf will attempt to load


However “theXML.xml” is actually located in www.mysite.com/images/myflash/theXML.xml
So Flash will not be able to load this content.

Some Flash content is written specifically to run in CMS enviroments where this problem occurs. These types of Flash content often allow the actual (absolute) path of the external assets e.g. the XML, to be specified using the “flashvars” parameter in the object and embed tags of the HTML. However this system is not generic and will only work for Flash swf’s with this additional feature.

Anyway, cutting to the chase, I wanted to display about 20+ Flash files in articles, all of which used external XML and none of which were designed to work in a CMS environment.

The easiest work around is to use an iFrame in the article to load a HTML page in the same folder as the Flash SWF, and that HTML page in turn loads the SWF.

This has some advantages as it allows the adobe approved HTML files created by Flash when you “Publish” the swf, to be used.

Unfortunately Joomla won’t let you put iFrames inside articles as it normally considers them to be a security risk. The security settings can be changes so that Joomla (or more specifically the content editors like MCE or JCE ) don’t do sytax checking; however changing global security settings just to allow one extra tag to be available seems a bad idea to me.

A better solution is to use a plugin like mosiFrame which allows iFrames to be inserted using a custom syntax.

With mosiFrame installed (and enabled), references to the HTML page for the SWF can be included in the article. For example

{iframe width=”640″ height=”480″}images/myflash/theFlash.htm{/iframe}

Note that the full (absolute) path to the XML file is not needed. Where possible its best to use relative paths, as this allows greater flexibility if you ever want to change the URL of the whole site, For example if the site becomes a sub-site of a larger site.

As a final note. I’ve tested whether using SWFObject would be a possible solution to this problem, but unfortunately in the tests that I’ve conducted, SWFObject has the same problems.So the iFrame work-around seems to be the best one I’ve found so far.