Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Using Express Install with SWFObject

Using Express Install with SWFObject

SWFObject has full support for the Express Install feature in Flash Player 8. Included with the SWFObject script is an ActionScript file that works with SWFObject to start the upgrade process in your SWFs. Your users never have to leave your site to upgrade their player, and when the upgrade is complete, they will be redirected back to the page that started the upgrade.

To use Express Install, you must first include the expressinstall.as file in your FLA. At the start of your SWF file, do a simple check to see if the user needs to be upgraded:

#include "expressinstall.as"

// initialize the ExpressInstall object
var ExpressInstall = new ExpressInstall();

// if the user needs to upgrade, show the 'start upgrade' button
if (ExpressInstall.needsUpdate) {

// this is optional, you could also automatically start the
// upgrade by calling ExpressInstall.init()
// here instead of the following lines
// attach the custom upgrade message and center it

var upgradeMsg = attachMovie("upgradeMsg_src", "upgradeMsg", 1);
upgradeMsg._x = Stage.width / 2;
upgradeMsg._y = Stage.height / 2;

// attach the button actions that will start the ExpresInstall updater
upgradeMsg.upgradeBtn.onRelease = function() {
// the ExpressInstall.init() method is what kicks off the actual update
ExpressInstall.init();
}
// if expressinstall is invoked, stop the timeline.
stop();
}

Note: In this example, I am using a custom upgrade message. Because of changes in the way that Flash 8 publishes SWF files, the content you may use in the custom upgrade message is very limited. TextFields should be set to use device fonts and any outlines or strokes on objects should either be set to hairline or removed entirely. If you are having trouble with content not showing up in your custom upgrade message, try simplifying the objects. Alternatively, simply invoke the upgrade process without a custom message (see the sample code in the included FLA).

For a local example of this Express Install code, open the fo_tester.fla file in the source folder contained in the sample download ZIP file. If you want to see Express Install in action on the web, install Flash Player 7 (or 6.0.65) and visit my SWFObject Express Install page.

If your SWF is in a pop-up window, or you wish to redirect the user to a different location after they complete the Express Install update, you can use the optional xiRedirectUrl attribute to redirect the user back to your landing page instead of the actual page containing your SWF:

<script type="text/javascript">
var so = new SWFObject("movie.swf",
"mymovie", "200", "100", "8", "#336699", true);
fo.setAttribute('xiRedirectUrl',
'http://www.example.com/upgradefinished.html');
// must be the absolute URL to your site
fo.write("flashcontent");
</script>

Comments