1  /**
     2   * properties.DisplayShortcuts.as
     3   * List of default special MovieClip properties (normal and splitter properties) for the Tweener class
     4   * The function names are strange/inverted because it makes for easier debugging (alphabetic order). They're only for internal use (on this class) anyways.
     5   *
     6   * @author		Zeh Fernando, Nate Chatellier, Arthur Debert
     7   * @version		1.0.0
     8   */
     9  
    10  import flash.geom.Point;
    11  import flash.geom.Rectangle;
    12  
    13  import caurina.transitions.Tweener;
    14  
    15  class caurina.transitions.properties.DisplayShortcuts {
    16  
    17  	/**
    18  	 * There's no constructor.
    19  	 */
    20  	public function DisplayShortcuts () {
    21  		trace ("This is an static class and should not be instantiated.")
    22  	}
    23  
    24  	/**
    25  	 * Registers all the special properties to the Tweener class, so the Tweener knows what to do with them.
    26  	 */
    27  	public static function init():Void {
    28  
    29  		// Normal properties
    30  		Tweener.registerSpecialProperty("_frame", _frame_get, _frame_set);
    31  		Tweener.registerSpecialProperty("_autoAlpha", _autoAlpha_get, _autoAlpha_set);
    32  
    33  		// Scale splitter properties
    34  		Tweener.registerSpecialPropertySplitter("_scale", _scale_splitter);
    35  
    36  		// scrollRect splitter properties
    37  		Tweener.registerSpecialPropertySplitter("_scrollRect", _scrollRect_splitter);
    38  		
    39  		// scrollrect normal properties
    40  		Tweener.registerSpecialProperty("_scrollRect_x",		_scrollRect_property_get, _scrollRect_property_set, ["x"]);
    41  		Tweener.registerSpecialProperty("_scrollRect_y",		_scrollRect_property_get, _scrollRect_property_set, ["y"]);
    42  		Tweener.registerSpecialProperty("_scrollRect_left",		_scrollRect_property_get, _scrollRect_property_set, ["left"]);
    43  		Tweener.registerSpecialProperty("_scrollRect_right",	_scrollRect_property_get, _scrollRect_property_set, ["right"]);
    44  		Tweener.registerSpecialProperty("_scrollRect_top",		_scrollRect_property_get, _scrollRect_property_set, ["top"]);
    45  		Tweener.registerSpecialProperty("_scrollRect_bottom",	_scrollRect_property_get, _scrollRect_property_set, ["bottom"]);
    46  		Tweener.registerSpecialProperty("_scrollRect_width",	_scrollRect_property_get, _scrollRect_property_set, ["width"]);
    47  		Tweener.registerSpecialProperty("_scrollRect_height",	_scrollRect_property_get, _scrollRect_property_set, ["height"]);
    48  
    49  	}
    50  
    51  
    52  	// ==================================================================================================================================
    53  	// PROPERTY GROUPING/SPLITTING functions --------------------------------------------------------------------------------------------
    54  
    55  	// ----------------------------------------------------------------------------------------------------------------------------------
    56  	// scale
    57  	public static function _scale_splitter(p_value:Number, p_parameters:Array) : Array{
    58  		var nArray:Array = new Array();
    59  		nArray.push({name:"_xscale", value: p_value});
    60  		nArray.push({name:"_yscale", value: p_value});
    61  		return nArray;
    62  	}
    63  
    64  	// ----------------------------------------------------------------------------------------------------------------------------------
    65  	// _scrollRect
    66  
    67  	/**
    68  	 * Splits the _scrollRect parameter into specific scrollRect variables
    69  	 *
    70  	 * @param		p_value				Rectangle	The original _scrollRect rectangle
    71  	 * @return							Array		An array containing the .name and .value of all new properties
    72  	 */
    73  	public static function _scrollRect_splitter (p_value:Rectangle, p_parameters:Array):Array {
    74  		var nArray:Array = new Array();
    75  		if (p_value == null) {
    76  			// No parameter passed, so try any rectangle :/
    77  			nArray.push({name:"_scrollRect_x", value:0});
    78  			nArray.push({name:"_scrollRect_y", value:0});
    79  			nArray.push({name:"_scrollRect_width", value:100});
    80  			nArray.push({name:"_scrollRect_height", value:100});
    81  		} else {
    82  			// A rectangle is passed, so just return the properties
    83  			nArray.push({name:"_scrollRect_x", value:p_value.x});
    84  			nArray.push({name:"_scrollRect_y", value:p_value.y});
    85  			nArray.push({name:"_scrollRect_width", value:p_value.width});
    86  			nArray.push({name:"_scrollRect_height", value:p_value.height});
    87  		}
    88  		return nArray;
    89  	}
    90  
    91  
    92  	// ==================================================================================================================================
    93  	// NORMAL SPECIAL PROPERTY functions ------------------------------------------------------------------------------------------------
    94  
    95  	// ----------------------------------------------------------------------------------------------------------------------------------
    96  	// _frame
    97  
    98  	/**
    99  	 * Returns the current frame number from the movieclip timeline
   100  	 *
   101  	 * @param		p_obj				Object		MovieClip object
   102  	 * @return							Number		The current frame
   103  	 */
   104  	public static function _frame_get (p_obj:Object):Number {
   105  		return p_obj._currentframe;
   106  	}
   107  
   108  	/**
   109  	 * Sets the timeline frame
   110  	 *
   111  	 * @param		p_obj				Object		MovieClip object
   112  	 * @param		p_value				Number		New frame number
   113  	 */
   114  	public static function _frame_set (p_obj:Object, p_value:Number):Void {
   115  		p_obj.gotoAndStop(Math.round(p_value));
   116  	}
   117  
   118  	
   119  	// ----------------------------------------------------------------------------------------------------------------------------------
   120  	// _autoAlpha
   121  
   122  	/**
   123  	 * Returns the current alpha
   124  	 *
   125  	 * @param		p_obj				Object		MovieClip or Textfield object
   126  	 * @return							Number		The current alpha
   127  	 */
   128  	public static function _autoAlpha_get (p_obj:Object):Number {
   129  		return p_obj._alpha;
   130  	}
   131  
   132  	/**
   133  	 * Sets the current autoAlpha
   134  	 *
   135  	 * @param		p_obj				Object		MovieClip or Textfield object
   136  	 * @param		p_value				Number		New alpha
   137  	 */
   138  	public static function _autoAlpha_set (p_obj:Object, p_value:Number):Void {
   139  		p_obj._alpha = p_value;
   140  		p_obj._visible = p_value > 0;
   141  	}
   142  
   143  	// ----------------------------------------------------------------------------------------------------------------------------------
   144  	// _scrollRect_*
   145  
   146  	/**
   147  	 * _scrollRect_*
   148  	 * Generic function for the properties of the scrollRect object
   149  	 */
   150  	public static function _scrollRect_property_get (p_obj:Object, p_parameters:Array):Number {
   151  		return p_obj.scrollRect[p_parameters[0]];
   152  	}
   153  	public static function _scrollRect_property_set (p_obj:Object, p_value:Number, p_parameters:Array):Void {
   154  		var rect:Rectangle = p_obj.scrollRect;
   155  		rect[p_parameters[0]] = Math.round(p_value);
   156  		p_obj.scrollRect = rect;
   157  	}
   158  }
   159