Git Repository Public Repository

CPE_learningsite

URLs

Copy to Clipboard

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.effects.effectClasses
{
	
	import mx.effects.effectClasses.AnimatePropertyInstance;
	import com.util.ColorUtil;
	
	/**
	 * 
	 */
	public class AnimateColorInstance extends AnimatePropertyInstance
	{
		/** The start color values for each of the r, g, and b channels */
		protected var startValues:Object;;
		
		/** The change in color value for each of the r, g, and b channels. */
		protected var delta:Object;
		
		/**
		 * Constructor
		 *
		 * @param target The Object to animate with this effect.
		 */
		public function AnimateColorInstance( target:Object )
		{
			super( target );
		}
		
		/**
		 * @private
		 */
		override public function play():void
		{
			// We need to call play first so that the fromValue is
			// correctly set, but this has the side effect of calling
			// onTweenUpdate before startValues or delta can be set,
			// so we need to check for that in onTweenUpdate to avoid
			// run time errors.
			super.play();
			
			// Calculate the delta for each of the color values
			startValues = ColorUtil.intToRgb( fromValue );
			var stopValues:Object = ColorUtil.intToRgb( toValue );
			delta = {
				r: ( startValues.r - stopValues.r ) / duration,
					g: ( startValues.g - stopValues.g ) / duration,
					b: ( startValues.b - stopValues.b ) / duration
			};
			
		}
		
		/**
		 * @private
		 */
		override public function onTweenUpdate( value:Object ):void
		{
			// Bail out if delta hasn't been set yet
			if ( delta == null )
			{
				return;
			}
			
			// Catch the situation in which the playheadTime is actually more
			// than duration, which causes incorrect colors to appear at the 
			// end of the animation.
			var playheadTime:int = this.playheadTime;
			if ( playheadTime > duration )
			{
				// Fix the local playhead time to avoid going past the end color
				playheadTime = duration;
			}
			
			// Calculate the new color value based on the elapased time and the change
			// in color values
			var colorValue:int = ( ( startValues.r - playheadTime * delta.r ) << 16 )
				+ ( (startValues.g - playheadTime * delta.g ) << 8 )
				+ ( startValues.b - playheadTime * delta.b );
			
			// Either set the property directly, or set it as a style
			if ( !isStyle )
			{
				target[ property ] = colorValue;
			}
			else
			{
				target.setStyle( property, colorValue );
			}
		}
		
	} // end class
} // end package

Commits for CPE_learningsiteCPEFlex/EngagementPod/src/com/effects/effectClasses/AnimateColorInstance.as

Diff revisions: vs.
Revision Author Commited Message
4cd176 ... v.shishlov Fri 27 Aug, 2021 14:33:17 +0000

initial commit