PageRenderTime 26ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 0ms app.codeStats 0ms

/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 **/
 7package com.greensock.plugins {
 8	import com.greensock.*;
 9	
10	import flash.display.*;
11/**
12 * Tweens a MovieClip to a particular frame number. <br /><br />
13 * 
14 * <b>USAGE:</b><br /><br />
15 * <code>
16 * 		import com.greensock.TweenLite; <br />
17 * 		import com.greensock.plugins.TweenPlugin; <br />
18 * 		import com.greensock.plugins.FramePlugin; <br />
19 * 		TweenPlugin.activate([FramePlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
20 * 
21 * 		TweenLite.to(mc, 1, {frame:125}); <br /><br />
22 * </code>
23 * 
24 * Note: When tweening the frames of a MovieClip, any audio that is embedded on the MovieClip's timeline (as "stream") will not be played. 
25 * Doing so would be impossible because the tween might speed up or slow down the MovieClip to any degree.<br /><br />
26 * 
27 * <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.
28 * 
29 * @author Jack Doyle, jack@greensock.com
30 */
31	public class FramePlugin extends TweenPlugin {
32		/** @private **/
33		public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
34		
35		/** @private **/
36		public var frame:int;
37		/** @private **/
38		protected var _target:MovieClip;
39		
40		/** @private **/
41		public function FramePlugin() {
42			super();
43			this.propName = "frame";
44			this.overwriteProps = ["frame","frameLabel"];
45			this.round = true;
46		}
47		
48		/** @private **/
49		override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
50			if (!(target is MovieClip) || isNaN(value)) {
51				return false;
52			}
53			_target = target as MovieClip;
54			this.frame = _target.currentFrame;
55			addTween(this, "frame", this.frame, value, "frame");
56			return true;
57		}
58		
59		/** @private **/
60		override public function set changeFactor(n:Number):void {
61			updateTweens(n);
62			_target.gotoAndStop(this.frame);
63		}
64
65	}
66}