1  /**
     2   * com.sekati.net.ExpressInstall
     3   * @version 1.1.0
     4   * @author jason m horwitz | sekati.com
     5   * Copyright (c) 2007  jason m horwitz | Sekat LLC. All Rights Reserved.
     6   * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
     7   */
     8   
     9  import com.sekati.core.FWDepth;
    10  import com.sekati.events.Event;
    11  import com.sekati.events.Dispatcher;
    12  /**
    13   * This class invokes the Adobe  Flash Player Express Install functionality if an update is required.
    14   * {@code Flash Usage:
    15   * // first line of code in your fla (before preloader) 
    16   * var expressinstall:ExpressInstall = new ExpressInstall();
    17   * }
    18   * {@code swfIN Usage:
    19   * <script type="text/javascript"> 
    20   * 	var f = new swfIN("foo.swf", "foo", "640", "480"); 
    21   * 	f.useExpressInstall();
    22   * 	f.detect(9, "d", "no_flash");
    23   * 	f.write();
    24   * </script>
    25   * }
    26   * Note: Your Flash movie must be at least 214px by 137px in order to use ExpressInstall.
    27   */
    28  class com.sekati.net.ExpressInstall {
    29  	private var _this:ExpressInstall;
    30  	private var _updater:MovieClip;
    31  	private var _holder:MovieClip;
    32  	/**
    33  	 * Constructor checks flash player version and stops movie to
    34  	 * invokes Express Install if update is required.
    35  	 */
    36  	public function ExpressInstall() {
    37  		_this = this;
    38  		if (_root.MMplayerType != undefined)  loadUpdater( );
    39  	}
    40  	private function loadUpdater():Void {
    41  		_root.stop( );
    42  		System.security.allowDomain( "fpdownload.macromedia.com" );
    43  		_updater = _root.createEmptyMovieClip( "expressInstallHolder", FWDepth.ExpressInstall );
    44  		// register the callback so we know if they cancel or there is an error
    45  		_updater.installStatus = onInstallStatus;
    46  		_holder = _updater.createEmptyMovieClip( "_holder", 1 );
    47  		// can't use movieClipLoader because it has to work in 6.0.65
    48  		_updater.onEnterFrame = function ():Void {
    49  			if (typeof _holder.startUpdate == "function") {
    50  				_this.initUpdater( );
    51  				_updater.onEnterFrame = null;
    52  			}
    53  		};
    54  		_holder.loadMovie( "http://fpdownload.macromedia.com/pub/flashplayer/" + "update/current/swf/autoUpdater.swf?" + Math.random( ) );
    55  	}
    56  	private function initUpdater():Void {
    57  		_holder.redirectURL = _level0.MMredirectURL;
    58  		_holder.MMplayerType = _level0.MMplayerType;
    59  		_holder.MMdoctitle = _level0.MMdoctitle;
    60  		_holder.startUpdate( );
    61  	}
    62  	/**
    63  	 * onInstallStatus event handler method
    64  	 * @param msg (String) status message
    65  	 * @return Void
    66  	 */
    67  	public function onInstallStatus(msg:String):Void {
    68  		Dispatcher.$.dispatchEvent( new Event( "ExpressInstall_onInstallStatus", this, {message:msg} ) );
    69  	}
    70  }