1 /** 2 * com.sekati.effects.AnimHandler 3 * @version 1.0.5 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.display.BaseClip; 10 import com.sekati.utils.ClassUtils; 11 12 /** 13 * Create an animation handler object to preserve 14 * the objects natural onEnterFrame event. 15 */ 16 class com.sekati.effects.AnimHandler { 17 18 /** 19 * Create a {@link com.sekati.display.BaseClip} onEnterFrame animation 20 * handler object for text effects. Only one anim handler per TextField; 21 * old or running anim handlers are automatically removed and overwritten 22 * to prevent animation overlaps. 23 * @param tf (TextField) target text 24 * @return MovieClip 25 */ 26 public static function create(tf:TextField):MovieClip { 27 var cName:String = "$__" + tf._name + "__anim__"; 28 29 var oldAnim:BaseClip = tf._parent[cName]; 30 if (oldAnim) { 31 oldAnim.destroy( ); 32 } 33 return ClassUtils.createEmptyMovieClip( com.sekati.display.BaseClip, tf._parent, cName ); 34 } 35 36 /** 37 * Destroy an animation. 38 * @param tf (TextField) target text 39 * @return Void 40 */ 41 public static function destroy(tf:TextField):Void { 42 var cName:String = "$__" + tf._name + "__anim__"; 43 var oldAnim:BaseClip = tf._parent[cName]; 44 if (oldAnim) { 45 oldAnim.onEnterFrame = null; 46 oldAnim.destroy( ); 47 } 48 } 49 50 private function AnimHandler() { 51 } 52 }