degrade

Degrade gracefuly

A common use case is to have a flash application, and degrade to the js (jeash) compiled version if the flash plugin is not available. Often, this is done differently depending on needs and requirements, but the following tip can be used as a code example for snooping and deploying the best version.

A community member (David Peek) contributed the following javascript wrapper script showing how this can be done - note that this technique requires prior embedding of the swfobject library:

<script type="text/javascript" charset="utf-8">
if (SWFObject.getQueryParamValue("flash") != "0" && SWFObject.hasFlashPlayerVersion("10.0.0"))
{
SWFObject.embedSWF("JeashTest.swf", "haxe:jeash", "100%", "100%", "10.0.0", "ExpressInstall.swf", {}, {allowscriptaccess:true,allowfullscreen:true,allownetworking:true,wmode:"opaque"}, {});
}
else
{
var app = document.createElement("script");
app.setAttribute("type","text/javascript");
app.setAttribute("src", "JeashTest.js");
document.getElementsByTagName("head")[0].appendChild(app)
}
</script>

Note: using a query parameter "flash=0" will force the javascript to override the flash version.

version #10574, modified 2011-05-19 22:14:04 by grumpytoad