Thursday, November 12, 2009

SWFAddress 2.4 and SWFObject 2.2 Static with Flex 3

SWFAddress 2.4 is fairly new and most people who want to implement SWFObject under it seem to like the dynamic version so I had a little bit of trouble finding good info on these specific versions. The general info did seem to work out all right but it would have been nice to have seen a more specific example, so here it is:

There are plenty of examples implementing either one of SWFObject or SWFAddress alone but together there are a few issues to be aware of.


<script type="text/javascript" src="assets/js/swfobject.js"></script>
<script type="text/javascript" src="assets/js/swfaddress.js"></script>
<script type="text/javascript">
function outputStatus(e)
{
alert("e.success = " + e.success +"\ne.id = "+ e.id +"\ne.ref = "+ e.ref);
}
swfobject.registerObject("${application}", "9.0.0", "assets/swf/expressInstall.swf", outputStatus);
</script>

<div>
<object id="${application}" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}">
<param name="movie" value="${swf}.swf" />
<param name="bgcolor" value="${bgcolor}" />
<param name="flashVars" value="test=true&test2=false" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}" height="${height}">
<!--<![endif]-->
<div>
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>


The main thing to keep in mind here is the order in which the JavaScript is invoked.
  1. The script reference to SWFObject first
  2. then SWFaddress
  3. finally the method call to registerObject
If you use the code above and implement the Flex code correctly (you can use the sample SWF that comes with the SWFAddress download to test) You will have successfully merged SWFAddress and SWFObject with a static implementation for your Flex application!

1 comment:

  1. The information here is great. I will invite my friends here.

    Thanks

    ReplyDelete