/src/com/greensock/plugins/FramePlugin.as

https://bitbucket.org/HopeSky/mars_nd2d · ActionScript · 66 lines · 28 code · 6 blank · 32 comment · 2 complexity · ffc6ea62ac526081d2ba56013c83b14c MD5 · raw file

  1. /**
  2. * VERSION: 1.03
  3. * DATE: 10/2/2009
  4. * ACTIONSCRIPT VERSION: 3.0
  5. * UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com
  6. **/
  7. package com.greensock.plugins {
  8. import com.greensock.*;
  9. import flash.display.*;
  10. /**
  11. * Tweens a MovieClip to a particular frame number. <br /><br />
  12. *
  13. * <b>USAGE:</b><br /><br />
  14. * <code>
  15. * import com.greensock.TweenLite; <br />
  16. * import com.greensock.plugins.TweenPlugin; <br />
  17. * import com.greensock.plugins.FramePlugin; <br />
  18. * TweenPlugin.activate([FramePlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
  19. *
  20. * TweenLite.to(mc, 1, {frame:125}); <br /><br />
  21. * </code>
  22. *
  23. * Note: When tweening the frames of a MovieClip, any audio that is embedded on the MovieClip's timeline (as "stream") will not be played.
  24. * Doing so would be impossible because the tween might speed up or slow down the MovieClip to any degree.<br /><br />
  25. *
  26. * <b>Copyright 2011, GreenSock. All rights reserved.</b> This work is subject to the terms in <a href="http://www.greensock.com/terms_of_use.html">http://www.greensock.com/terms_of_use.html</a> or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
  27. *
  28. * @author Jack Doyle, jack@greensock.com
  29. */
  30. public class FramePlugin extends TweenPlugin {
  31. /** @private **/
  32. public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
  33. /** @private **/
  34. public var frame:int;
  35. /** @private **/
  36. protected var _target:MovieClip;
  37. /** @private **/
  38. public function FramePlugin() {
  39. super();
  40. this.propName = "frame";
  41. this.overwriteProps = ["frame","frameLabel"];
  42. this.round = true;
  43. }
  44. /** @private **/
  45. override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
  46. if (!(target is MovieClip) || isNaN(value)) {
  47. return false;
  48. }
  49. _target = target as MovieClip;
  50. this.frame = _target.currentFrame;
  51. addTween(this, "frame", this.frame, value, "frame");
  52. return true;
  53. }
  54. /** @private **/
  55. override public function set changeFactor(n:Number):void {
  56. updateTweens(n);
  57. _target.gotoAndStop(this.frame);
  58. }
  59. }
  60. }