Tip: Detect whether Flash is available

Monday, June 09, 2008 at 1:58 PM



Before you a embed a Flash movie into your gadget, check whether the Adobe Flash plugin is indeed available on the user's machine. Here's a function that returns true if you can use Flash.
function flashAvailable() {
if (framework.system.machine.manufacturer == "Apple") {
// It's pretty safe to just assume that Flash is on the Mac;
// it's preinstalled with Safari.
return true;
}

var flashCode = "<object x='0' y='0' name='flashCheck'
visible='false' classid='progid:ShockwaveFlash.ShockwaveFlash'
width='1' height='1'><param name='movie' value='none.swf' /></object>";

var tmpEle = view.appendElement(flashCode);
if (tmpEle == null) {
return false;
} else {
view.removeElement(tmpEle);
return true;
}
}
Have a tip you'd like to share? Send it to gd-developer AT google DOT com. To see all tips, choose the Tips label.

No comments: