Flash, XML and Expression Engine

In Assignment, Expression Engine, Technical on April 17, 2010 at 12:36 pm

I’d like to outline the ways in which I have used Flash and XML to communicate with Expression Engine, since it is the core functionality for playing the music on the site.

I have used Flash in 2 ways; firstly, as an album player that opens in a popup window so that the user can continue to view the site, without interupting the music, while the player takes care of playing the whole album; and secondly, as an inline element on the album page, as part of the tracklist, in which case the Flash element is only concerned with playing that individual track.

Album Player

  • The album must open in a new popup window
  • The Flash movie must then determine which album to play and then play it

The page has a javascript function to take care of the popup:

<script type="text/javascript">
<!-- Hide from old browsers
function openWin(url) {
var w_left = Math.ceil(screen.width/2-300);
var openWin =,"VoteWin","left="+w_left+",top=30,scrollbars=no,menubar=no,height=365,width=515,resizable=yes,toolbar=no,location=no,status=no");

The link needed to call this function looks like this:

<a href="javascript:openWin('http://www.site_domain/index.php/Albums/Popout?id=Get Knotted')"....

In the above code, Popout is a page template in Expression Engine which is handed the variable ‘id’ which is the name of the album that Flash will need to play:

Popout?id=Get Knotted

When the popout window is called it retrieves the album name from the url with the php script, <?php $id=$_GET["id"];?>
When the Flash movie is embedded into the page, the album name variable is passed to it by appending the swf file name with the variable, using the php echo function:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="350\">
<param name="movie" value="{site_url}flash/EE-XML-load-test.swf?id=<?php echo $id; ?>" />

When the swf file loads it immediately calls for an XML file from Expression Engine using the actionscript:

var xmlURL:String = "http://site_url/index.php/Albums/Albums_XML/";
XML = new XML();
XML.ignoreWhite = true;
XML.onLoad = Play_Album_Function;

Expression Engine then converts relevant content into XML using the script:

{exp:weblog:entries weblog="albums" }
<Album Artist="{BandName}" Album="{title}" PictureFile="{AlbumPic}" Tracks="{TrackNames}" Files="{FileNames}" Basepath="{Basepath}" />

Flash then constructs a series of arrays based upon the above variables, loading ALL albums data into its memory. The arrays are associated by default through their index reference. It is a rather scenic route to get there, but Flash then searches its album_tile_name array for a match with the id variable it was given through the html markup Flashmovie.swf?id=Get Knotted

Because Expression Engine created both the XML file and the html markup to append the swf file name with the album title to match it to, a match will be assured, as long as Flash successfully loads the XML file.

With that all in place, Flash then goes on to playing the album, and I’m off to do something else. Bye…!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: