1  /**
     2   * com.sekati.ui.ScreenProtector
     3   * @version 1.0.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.CoreObject;
    10  import com.sekati.core.FWDepth;
    11  import com.sekati.display.BaseClip;
    12  import com.sekati.draw.Rectangle;
    13  import com.sekati.geom.Point;
    14  import com.sekati.utils.ClassUtils;
    15  
    16  /**
    17   * Lock the Screen from UI interaction.
    18   * {@code Usage:
    19   * 	var protect:ScreenProjector = new ScreenProtector();
    20   * 	protect.destroy(); // enable;
    21   * }
    22   */
    23  class com.sekati.ui.ScreenProtector extends CoreObject {
    24  
    25  	private var _cover:MovieClip;
    26  	private var _isLocked:Boolean;
    27  
    28  	/**
    29  	 * Constructor - create an invisible clip which locks the entire screen.
    30  	 */
    31  	public function ScreenProtector() {
    32  		super( );
    33  		_cover = ClassUtils.createEmptyMovieClip( com.sekati.display.BaseClip, _root, "__ScreenProtector__", {_x:0, _y:0, _alpha:0, _depth:FWDepth.ScreenProtector} );
    34  		Rectangle.draw( _cover, new Point( 0, 0 ), new Point( Stage.width, Stage.height ), 0xFF00FF, 0 );
    35  		_cover.onPress = new Function( );
    36  		_cover.useHandCursor = false;
    37  		_isLocked = true;
    38  	}
    39  
    40  	/**
    41  	 * Update ScreenProtector to highest depth.
    42  	 * @return Void
    43  	 */
    44  	public function update():Void {
    45  		_cover.swapDepths( _level0 );
    46  	}
    47  
    48  	/**
    49  	 * isLocked getter.
    50  	 * @return Boolean.
    51  	 */
    52  	public function get enabled():Boolean {
    53  		return _isLocked;	
    54  	}
    55  
    56  	/**
    57  	 * isLocked setter.
    58  	 * @return Boolean
    59  	 */
    60  	public function set enabled(b:Boolean):Void {
    61  		_isLocked = b;
    62  		if (b) {
    63  			update( );	
    64  		}
    65  	}
    66  
    67  	/**
    68  	 * Destroy the cover and instance.
    69  	 * @return Void
    70  	 */	
    71  	public function destroy():Void {
    72  		_cover.destroy( );
    73  		super.destroy( );
    74  	}
    75  }