1  /**
     2   * com.sekati.transitions.Mot
     3   * @version 1.1.0
     4   * @author jason m horwitz | sekati.com | tendercreative.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 caurina.transitions.Tweener;
    10  
    11  /**
    12   * Mot - Motion Styling template support for {@link caurina.transitions.Tweener}
    13   * {@code Usage:
    14   * 	Tweener.addTween(myMc, { _x:500, _y:30, base:Mot.base0 } );
    15   * 	Tweener.addTween(myMc, { base:Mot.fadeOut } );
    16   * 	Tweener.addTween(myMc, { base:Mot.fadeTo(50), onComplete:myCallBackFn} );
    17   * }
    18   */
    19  class com.sekati.transitions.Mot {
    20  
    21  	// easing shortcuts
    22  	public static var i:Object = { quint:"easeInQuint", quad:"easeInQuad", quart:"easeInQuart", expo:"easeInExpo" };
    23  	public static var o:Object = { quint:"easeOutQuint", quad:"easeOutQuad", quart:"easeOutQuart", expo:"easeOutExpo" };
    24  	public static var io:Object = { quint:"easeInOutQuint", quad:"easeInOutQuad", quart:"easeInOutQuart", expo:"easeInOutExpo" };
    25  	// timing shortcuts
    26  	public static var t:Object = {s:0.3, s2:0.5, s3:0.7, d:0.3, d2:0.5, d3:1};
    27  	// deprecated "App.mot" mc_tween2 object - kept for backwards compatability
    28  	public static var m:Object = {e:"easeInOutQuint", e2:"easeOutQuint", e3:"easeInOutQuad", e4:"easeOutQuad", e5:"easeInOutQuart", e6:"easeOutQuart", e7:"easeInOutExpo", e8:"easeOutExpo", s:0.3, s2:0.5, d:0.5};
    29  	// color shortcuts
    30  	public static var col:Object = {b:0x000000, w:0xFFFFFF, r:0xFF0000, g:0x00FF00, b:0x0000FF, y:0xFFFF00, c:0x00FFFF, m:0xFF00FF};
    31  	public static var chromo:Object = {
    32  		month:{jan:0x00D294, feb:0x26E058, mar:0xBCFF2D, apr:0xFFFF41, may:0xFFAF0B, jun:0xFF1A33, jul:0xFF1F77, aug:0xFB48BC, sep:0xBC35B7, oct:0x2463DB, nov:0x00A3FF, dec:0x00DCFF}, day:{a1:0x00D5E1, a2:0x00D294, a3:0x00CB58, a4:0x26E058, a5:0x7AF049, a6:0xBCFF2D, a7:0xFFFF22, a8:0xFFFF41, a9:0xFFFF30, a10:0xFFAF0B, a11:0xFF6E0C, a12:0xFF1A33, p1:0xFF0041, p2:0xFF1F77, p3:0xFF37B2, p4:0xFB48BC, p5:0xE638B5, p6:0xBC35B7, p7:0x7953CB, p8:0x2463DB, p9:0x0077EB, p10:0x00A3FF, p11:0x00C8FF, p12:0x00DCFF}
    33  	};
    34  
    35  	// preset templates
    36  	public static function get base0():Object { 
    37  		return { time:t.s, transition:io.quint };
    38  	}
    39  
    40  	public static function get base1():Object {
    41  		return { time:t.s, transition:io.quad };
    42  	}
    43  
    44  	public static function get base2():Object {
    45  		return { time:t.s, transition:io.expo };
    46  	}
    47  
    48  	public static function get abase():Object {
    49  		return {time:0.5, transition:o.quad };
    50  	}
    51  
    52  	public static function get abaseShort():Object {
    53  		return {time:0.3, transition:o.quad };
    54  	}
    55  
    56  	public static function get abaseLong():Object {
    57  		//return {time:1, transition:io.quad };
    58  		return {time:0.7, transition:io.quad };
    59  	}
    60  
    61  	public static function get fadeIn():Object {
    62  		return Mot.fadeTo( 100 );	
    63  	}
    64  
    65  	public static function get fadeOut():Object {
    66  		return Mot.fadeTo( 0 );	
    67  	}
    68  
    69  	/**
    70  	 * Return a base tween object alpha transition
    71  	 * @param a (Number)
    72  	 * @return Object
    73  	 */
    74  	public static function fadeTo(a:Number):Object {
    75  		return { _alpha:a, time:t.s, transition:io.expo };	
    76  	}
    77  
    78  	/**
    79  	 * Return a base tween object glow transition
    80  	 * @param a (Number) alpha [0-100]
    81  	 * @param b (Number) blur [0-255]
    82  	 * @param c (Number) color [hex]
    83  	 * @param s (Number) strength [0-255]
    84  	 * @return Object
    85  	 */
    86  	public static function glow(a:Number, b:Number, c:Number, s:Number):Object {
    87  		return {_Glow_alpha:a, _Glow_color:c, _Glow_quality:3, _Glow_strength:s, _Glow_blurX:b, _Glow_blurY:b};	
    88  	}
    89  
    90  	/**
    91  	 * Create a small "burst" transition
    92  	 * @param mc (MovieClip)
    93  	 * @param c (Number) color [hex]
    94  	 * @param cb (Function) callback
    95  	 * @return Void
    96  	 */	
    97  	public static function burst(mc:MovieClip, c:Number, cb:Function):Void {
    98  		Tweener.addTween( mc, {_scale:10, time:0.3, transition:Mot.o.quint} );
    99  		Tweener.addTween( mc, {_Glow_alpha:100, _Glow_color:c, _Glow_quality:3, _Glow_strength:10, _Glow_blurX:25, _Glow_blurY:25, _scale:150, time:0.3, transition:io.quad, delay:0.3} );
   100  		Tweener.addTween( mc, {_alpha:0, _scale:50, time:0.5, transition:Mot.o.quint, delay:0.6, onComplete:cb} );
   101  	}
   102  
   103  	/**
   104  	 * Normalize a clip
   105  	 * @param mc (MovieClip)
   106  	 * @return Void
   107  	 */
   108  	public static function normalize(mc:MovieClip):Void {
   109  		mc.filters = [];
   110  		mc._xscale = 100;
   111  		mc._yscale = 100;
   112  		Tweener.addTween( mc, {_color:undefined, time:0} );	
   113  	}
   114  
   115  	/**
   116  	 * Return a base tween object color transition
   117  	 * @param c (Number)
   118  	 * @return Object
   119  	 */
   120  	public static function colorTo(c:Number):Object {
   121  		return { _color:c, time:t.s2, transition:io.quint };	
   122  	}	
   123  
   124  	/**
   125  	 * Mot Private Constructor
   126  	 */
   127  	private function Mot() {
   128  	}
   129  }
   130