ExpressInstall.as 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Based on the expressinstall.as class created by Geoff Stearns as part
  3. * of the FlashObject library.
  4. *
  5. * Use this file to invoke the Macromedia Flash Player Express Install functionality
  6. * This file is intended for use with the FlashObject embed script. You can download FlashObject
  7. * and this file at the following URL: http://blog.deconcept.com/flashobject/
  8. *
  9. * Usage:
  10. * var ExpressInstall = new ExpressInstall();
  11. *
  12. * // test to see if install is needed:
  13. * if (ExpressInstall.needsUpdate) { // returns true if update is needed
  14. * ExpressInstall.init(); // starts the update
  15. * }
  16. *
  17. * NOTE: Your Flash movie must be at least 214px by 137px in order to use ExpressInstall.
  18. *
  19. */
  20. class ExpressInstall {
  21. public var needsUpdate:Boolean;
  22. private var updater:MovieClip;
  23. private var hold:MovieClip;
  24. public function ExpressInstall(){
  25. // does the user need to update?
  26. this.needsUpdate = (_root.MMplayerType == undefined) ? false : true;
  27. }
  28. public function init():Void{
  29. this.loadUpdater();
  30. }
  31. public function loadUpdater():Void {
  32. System.security.allowDomain("fpdownload.macromedia.com");
  33. // hope that nothing is at a depth of 10000000, you can change this depth if needed, but you want
  34. // it to be on top of your content if you have any stuff on the first frame
  35. this.updater = _root.createEmptyMovieClip("expressInstallHolder", 10000000);
  36. // register the callback so we know if they cancel or there is an error
  37. var _self = this;
  38. this.updater.installStatus = _self.onInstallStatus;
  39. this.hold = this.updater.createEmptyMovieClip("hold", 1);
  40. // can't use movieClipLoader because it has to work in 6.0.65
  41. this.updater.onEnterFrame = function():Void {
  42. if(typeof this.hold.startUpdate == 'function'){
  43. _self.initUpdater();
  44. this.onEnterFrame = null;
  45. }
  46. }
  47. var cacheBuster:Number = Math.random();
  48. this.hold.loadMovie("http://fpdownload.macromedia.com/pub/flashplayer/"
  49. +"update/current/swf/autoUpdater.swf?"+ cacheBuster);
  50. }
  51. private function initUpdater():Void{
  52. this.hold.redirectURL = _root.MMredirectURL;
  53. this.hold.MMplayerType = _root.MMplayerType;
  54. this.hold.MMdoctitle = _root.MMdoctitle;
  55. this.hold.startUpdate();
  56. }
  57. public function onInstallStatus(msg):Void{
  58. getURL("javascript:dojox.flash.install._onInstallStatus('"+msg+"')");
  59. }
  60. }