935b56a9 by Jeff Balicki

F

1 parent 31ad666c
Showing 114 changed files with 4776 additions and 0 deletions
This diff could not be displayed because it is too large.
1 /**
2 * VERSION: 0.86
3 * DATE: 6/15/2009
4 * AS2 (AS3 version is also available)
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenLite.com
6 **/
7 package com.greensock {
8 /**
9 * Static constants for defining tween alignment.
10 *
11 * <b>Copyright 2010, 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.
12 *
13 * @author Jack Doyle, jack@greensock.com
14 **/
15 public class TweenAlign {
16 public static const NORMAL:String = "normal";
17 public static const SEQUENCE:String = "sequence";
18 public static const START:String = "start";
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.1
3 * DATE: 2009-09-12
4 * ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available)
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenLite.com
6 **/
7 package com.greensock.core {
8 /**
9 * Stores information about an individual property tween. There is no reason to use this class directly - TweenLite, TweenMax, and some plugins use it internally.<br /><br />
10 *
11 * <b>Copyright 2010, 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.
12 *
13 * @author Jack Doyle, jack@greensock.com
14 */
15 public class PropTween {
16 /** Target object **/
17 public var target:Object;
18 /** Name of the property that is being tweened **/
19 public var property:String;
20 /** Starting value **/
21 public var start:Number;
22 /** Amount to change (basically, the difference between the starting value and ending value) **/
23 public var change:Number;
24 /** Alias to associate with the PropTween which is typically the same as the property, but can be different, particularly for plugins. **/
25 public var name:String;
26 /** Priority in the rendering queue. The lower the value the later it will be tweened. Typically all PropTweens get a priority of 0, but some plugins must be rendered later (or earlier) **/
27 public var priority:int;
28 /** If the target of the PropTween is a TweenPlugin, isPlugin should be true. **/
29 public var isPlugin:Boolean;
30 /** Next PropTween in the linked list **/
31 public var nextNode:PropTween;
32 /** Previous PropTween in the linked list **/
33 public var prevNode:PropTween;
34
35 /**
36 * Constructor
37 *
38 * @param target Target object
39 * @param property Name of the property that is being tweened
40 * @param start Starting value
41 * @param change Amount to change (basically, the difference between the starting value and ending value)
42 * @param name Alias to associate with the PropTween which is typically the same as the property, but can be different, particularly for plugins.
43 * @param isPlugin If the target of the PropTween is a TweenPlugin, isPlugin should be true.
44 * @param nextNode Next PropTween in the linked list
45 * @param priority Priority in the rendering queue. The lower the value the later it will be tweened. Typically all PropTweens get a priority of 0, but some plugins must be rendered later (or earlier)
46 */
47 public function PropTween(target:Object, property:String, start:Number, change:Number, name:String, isPlugin:Boolean, nextNode:PropTween=null, priority:int=0) {
48 this.target = target;
49 this.property = property;
50 this.start = start;
51 this.change = change;
52 this.name = name;
53 this.isPlugin = isPlugin;
54 if (nextNode) {
55 nextNode.prevNode = this;
56 this.nextNode = nextNode;
57 }
58 this.priority = priority;
59 }
60 }
61 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.38
3 * DATE: 2010-05-24
4 * AS3 (AS2 version is also available)
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenLite.com
6 **/
7 package com.greensock.core {
8 /**
9 * SimpleTimeline is the base class for the TimelineLite and TimelineMax classes. It provides the
10 * most basic timeline functionality and is used for the root timelines in TweenLite. It is meant
11 * to be very fast and lightweight. <br /><br />
12 *
13 * <b>Copyright 2010, 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.
14 *
15 * @author Jack Doyle, jack@greensock.com
16 */
17 public class SimpleTimeline extends TweenCore {
18 /** @private **/
19 protected var _firstChild:TweenCore;
20 /** @private **/
21 protected var _lastChild:TweenCore;
22 /** If a timeline's autoRemoveChildren is true, its children will be removed and made eligible for garbage collection as soon as they complete. This is the default behavior for the main/root timeline. **/
23 public var autoRemoveChildren:Boolean;
24
25 public function SimpleTimeline(vars:Object=null) {
26 super(0, vars);
27 }
28
29 /** @private **/
30 public function addChild(tween:TweenCore):void {
31 if (!tween.cachedOrphan && tween.timeline) {
32 tween.timeline.remove(tween, true); //removes from existing timeline so that it can be properly added to this one.
33 }
34 tween.timeline = this;
35 if (tween.gc) {
36 tween.setEnabled(true, true);
37 }
38 if (_firstChild) {
39 _firstChild.prevNode = tween;
40 }
41 tween.nextNode = _firstChild;
42 _firstChild = tween;
43 tween.prevNode = null;
44 tween.cachedOrphan = false;
45 }
46
47 /** @private **/
48 public function remove(tween:TweenCore, skipDisable:Boolean=false):void {
49 if (tween.cachedOrphan) {
50 return; //already removed!
51 } else if (!skipDisable) {
52 tween.setEnabled(false, true);
53 }
54
55 if (tween.nextNode) {
56 tween.nextNode.prevNode = tween.prevNode;
57 } else if (_lastChild == tween) {
58 _lastChild = tween.prevNode;
59 }
60 if (tween.prevNode) {
61 tween.prevNode.nextNode = tween.nextNode;
62 } else if (_firstChild == tween) {
63 _firstChild = tween.nextNode;
64 }
65 tween.cachedOrphan = true;
66 //don't null nextNode and prevNode, otherwise the chain could break in rendering loops.
67 }
68
69 /** @private **/
70 override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void {
71 var tween:TweenCore = _firstChild, dur:Number, next:TweenCore;
72 this.cachedTotalTime = time;
73 this.cachedTime = time;
74
75 while (tween) {
76 next = tween.nextNode; //record it here because the value could change after rendering...
77 if (tween.active || (time >= tween.cachedStartTime && !tween.cachedPaused && !tween.gc)) {
78 if (!tween.cachedReversed) {
79 tween.renderTime((time - tween.cachedStartTime) * tween.cachedTimeScale, suppressEvents, false);
80 } else {
81 dur = (tween.cacheIsDirty) ? tween.totalDuration : tween.cachedTotalDuration;
82 tween.renderTime(dur - ((time - tween.cachedStartTime) * tween.cachedTimeScale), suppressEvents, false);
83 }
84 }
85 tween = next;
86 }
87
88 }
89
90 //---- GETTERS / SETTERS ------------------------------------------------------------------------------
91
92 /**
93 * @private
94 * Reports the totalTime of the timeline without capping the number at the totalDuration (max) and zero (minimum) which can be useful when
95 * unpausing tweens/timelines. Imagine a case where a paused tween is in a timeline that has already reached the end, but then
96 * the tween gets unpaused - it needs a way to place itself accurately in time AFTER what was previously the timeline's end time.
97 * In a SimpleTimeline, rawTime is always the same as cachedTotalTime, but in TimelineLite and TimelineMax, it can be different.
98 *
99 * @return The totalTime of the timeline without capping the number at the totalDuration (max) and zero (minimum)
100 */
101 public function get rawTime():Number {
102 return this.cachedTotalTime;
103 }
104
105 }
106 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.01
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for filter tweens. See the documentation
8 in TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {bevelFilter:{distance:5, blurX:10, blurY:10, strength:2}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 myVars.bevelFilter = new BevelFilterVars(5, 10, 10, 2);
16 myVars.onComplete = myFunction;
17 TweenMax.to(my_mc, 1, myVars);
18
19
20 NOTES:
21 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenMax class, feel
22 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
23 - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly
24 data typed) syntax, like TweenMax.to(my_mc, 1, {bevelFilter:{blurX:"-5", blurY:"3"}});
25
26 AUTHOR: Jack Doyle, jack@greensock.com
27 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
28 */
29
30
31 package com.greensock.data {
32
33 public class BevelFilterVars extends FilterVars {
34 public var distance:Number;
35 public var blurX:Number;
36 public var blurY:Number;
37 public var strength:Number;
38 public var angle:Number;
39 public var highlightAlpha:Number;
40 public var shadowAlpha:Number;
41
42 public function BevelFilterVars(distance:Number=4, blurX:Number=4, blurY:Number=4, strength:Number=1, angle:Number=45, highlightAlpha:Number=1, highlightColor:uint=0xFFFFFF, shadowAlpha:Number=1, shadowColor:uint=0x000000, quality:uint=2, remove:Boolean=false, index:int=-1, addFilter:Boolean=false) {
43 super(remove, index, addFilter);
44 this.distance = distance;
45 this.blurX = blurX;
46 this.blurY = blurY;
47 this.strength = strength;
48 this.angle = angle;
49 this.highlightAlpha = highlightAlpha;
50 this.highlightColor = highlightColor;
51 this.shadowAlpha = shadowAlpha;
52 this.shadowColor = shadowColor;
53 this.quality = quality;
54 }
55
56 override protected function initEnumerables(nulls:Array, numbers:Array):void {
57 super.initEnumerables(nulls, numbers.concat(["distance","blurX","blurY","strength","angle","highlightAlpha","shadowAlpha"]));
58 }
59
60 public static function create(vars:Object):BevelFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
61 if (vars is BevelFilterVars) {
62 return vars as BevelFilterVars;
63 }
64 return new BevelFilterVars(vars.distance || 0,
65 vars.blurX || 0,
66 vars.blurY || 0,
67 (vars.strength == null) ? 1 : vars.strength,
68 (vars.angle == null) ? 45 : vars.angle,
69 (vars.highlightAlpha == null) ? 1 : vars.highlightAlpha,
70 (vars.highlightColor == null) ? 0xFFFFFF : vars.highlightColor,
71 (vars.shadowAlpha == null) ? 1 : vars.shadowAlpha,
72 (vars.shadowColor == null) ? 0xFFFFFF : vars.shadowColor,
73 vars.quality || 2,
74 vars.remove || false,
75 (vars.index == null) ? -1 : vars.index,
76 vars.addFilter || false);
77 }
78
79 //---- GETTERS / SETTERS --------------------------------------------------------------------------------------------
80
81 /** Highlight color. **/
82 public function get highlightColor():uint {
83 return uint(_values.highlightColor);
84 }
85 public function set highlightColor(value:uint):void {
86 setProp("highlightColor", value);
87 }
88
89 /** Shadow color. **/
90 public function get shadowColor():uint {
91 return uint(_values.shadowColor);
92 }
93 public function set shadowColor(value:uint):void {
94 setProp("shadowColor", value);
95 }
96
97 /** Quality (1, 2, or 3). **/
98 public function get quality():uint {
99 return uint(_values.quality);
100 }
101 public function set quality(value:uint):void {
102 setProp("quality", value);
103 }
104
105 }
106
107 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.01
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in
8 the TweenLiteVars or TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {blurFilter:{blurX:10, blurY:10}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 myVars.blurFilter = new BlurFilterVars(10, 10);
16 myVars.onComplete = myFunction;
17 TweenMax.to(my_mc, 1, myVars);
18
19
20 NOTES:
21 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel
22 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
23 - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly
24 data typed) syntax, like TweenMax.to(my_mc, 1, {blurFilter:{blurX:"-5", blurY:"3"}});
25
26 AUTHOR: Jack Doyle, jack@greensock.com
27 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
28 */
29
30
31 package com.greensock.data {
32 public class BlurFilterVars extends FilterVars {
33 public var blurX:Number;
34 public var blurY:Number;
35
36 public function BlurFilterVars(blurX:Number=10, blurY:Number=10, quality:uint=2, remove:Boolean=false, index:int=-1, addFilter:Boolean=false) {
37 super(remove, index, addFilter);
38 this.blurX = blurX;
39 this.blurY = blurY;
40 this.quality = quality;
41 }
42
43 override protected function initEnumerables(nulls:Array, numbers:Array):void {
44 super.initEnumerables(nulls, numbers.concat(["blurX","blurY"]));
45 }
46
47 public static function create(vars:Object):BlurFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
48 if (vars is BlurFilterVars) {
49 return vars as BlurFilterVars;
50 }
51 return new BlurFilterVars(vars.blurX || 0,
52 vars.blurY || 0,
53 vars.quality || 2,
54 vars.remove || false,
55 (vars.index == null) ? -1 : vars.index,
56 vars.addFilter || false);
57 }
58
59 //---- GETTERS / SETTERS ------------------------------------------------------------------------------
60
61 /** Quality (1, 2, or 3). **/
62 public function get quality():uint {
63 return uint(_values.quality);
64 }
65 public function set quality(value:uint):void {
66 setProp("quality", value);
67 }
68
69 }
70 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.01
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in
8 the TweenLiteVars or TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {colorMatrixFilter:{colorize:0xFF0000, amount:0.5}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 myVars.colorMatrixFilter = new ColorMatrixFilterVars(0xFF0000, 0.5);
16 myVars.onComplete = myFunction;
17 TweenMax.to(my_mc, 1, myVars);
18
19
20 NOTES:
21 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel
22 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
23 - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly
24 data typed) syntax, like TweenMax.to(my_mc, 1, {colorMatrixFilter:{contrast:0.5, relative:true}});
25
26 AUTHOR: Jack Doyle, jack@greensock.com
27 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
28 */
29
30
31 package com.greensock.data {
32 import com.greensock.plugins.*;
33
34 public class ColorMatrixFilterVars extends FilterVars {
35 protected static var _ID_MATRIX:Array = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];
36 protected static var _lumR:Number = 0.212671; //Red constant - used for a few color matrix filter functions
37 protected static var _lumG:Number = 0.715160; //Green constant - used for a few color matrix filter functions
38 protected static var _lumB:Number = 0.072169; //Blue constant - used for a few color matrix filter functions
39
40 public var matrix:Array;
41
42 public function ColorMatrixFilterVars(colorize:uint=0xFFFFFF, amount:Number=1, saturation:Number=1, contrast:Number=1, brightness:Number=1, hue:Number=0, threshold:Number=-1, remove:Boolean=false, index:int=-1, addFilter:Boolean=false) {
43 super(remove, index, addFilter);
44 this.matrix = _ID_MATRIX.slice();
45 if (brightness != 1) {
46 setBrightness(brightness);
47 }
48 if (contrast != 1) {
49 setContrast(contrast);
50 }
51 if (hue != 0) {
52 setHue(hue);
53 }
54 if (saturation != 1) {
55 setSaturation(saturation);
56 }
57 if (threshold != -1) {
58 setThreshold(threshold);
59 }
60 if (colorize != 0xFFFFFF) {
61 setColorize(colorize, amount);
62 }
63 }
64
65 override protected function initEnumerables(nulls:Array, numbers:Array):void {
66 super.initEnumerables(nulls.concat(["matrix"]), numbers);
67 }
68
69 public function setBrightness(n:Number):void {
70 this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setBrightness(this.matrix, n);
71 }
72 public function setContrast(n:Number):void {
73 this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setContrast(this.matrix, n);
74 }
75 public function setHue(n:Number):void {
76 this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setHue(this.matrix, n);
77 }
78 public function setSaturation(n:Number):void {
79 this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setSaturation(this.matrix, n);
80 }
81 public function setThreshold(n:Number):void {
82 this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setThreshold(this.matrix, n);
83 }
84 public function setColorize(color:uint, amount:Number=1):void {
85 this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.colorize(this.matrix, color, amount);
86 }
87
88 public static function create(vars:Object):ColorMatrixFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
89 var v:ColorMatrixFilterVars;
90 if (vars is ColorMatrixFilterVars) {
91 v = vars as ColorMatrixFilterVars;
92 } else if (vars.matrix != null) {
93 v = new ColorMatrixFilterVars();
94 v.matrix = vars.matrix;
95 } else {
96 v = new ColorMatrixFilterVars(vars.colorize || 0xFFFFFF,
97 (vars.amount == null) ? 1 : vars.amount,
98 (vars.saturation == null) ? 1 : vars.saturation,
99 (vars.contrast == null) ? 1 : vars.contrast,
100 (vars.brightness == null) ? 1 : vars.brightness,
101 vars.hue || 0,
102 (vars.threshold == null) ? -1 : vars.threshold,
103 vars.remove || false,
104 (vars.index == null) ? -1 : vars.index,
105 vars.addFilter || false);
106 }
107 return v;
108 }
109
110
111 }
112
113 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.0
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for colorTransform tweens. See the documentation in
8 the TweenLiteVars or TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {colorTransform:{exposure:2}}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 var ct:ColorTransformVars = new ColorTransformVars();
16 ct.exposure = 2;
17 myVars.colorTransform = ct;
18 myVars.onComplete = myFunction;
19 TweenMax.to(my_mc, 1, myVars);
20
21
22 NOTES:
23 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel
24 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
25 - You cannot define relative tween values with this utility.
26
27 AUTHOR: Jack Doyle, jack@greensock.com
28 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
29 */
30
31
32 package com.greensock.data {
33
34 public class ColorTransformVars extends VarsCore {
35 public var tintAmount:Number;
36 public var exposure:Number;
37 public var brightness:Number;
38 public var redMultiplier:Number;
39 public var redOffset:Number;
40 public var greenMultiplier:Number;
41 public var greenOffset:Number;
42 public var blueMultiplier:Number;
43 public var blueOffset:Number;
44 public var alphaMultiplier:Number;
45 public var alphaOffset:Number;
46
47 public function ColorTransformVars(tint:Number=NaN, tintAmount:Number=NaN, exposure:Number=NaN, brightness:Number=NaN, redMultiplier:Number=NaN, greenMultiplier:Number=NaN, blueMultiplier:Number=NaN, alphaMultiplier:Number=NaN, redOffset:Number=NaN, greenOffset:Number=NaN, blueOffset:Number=NaN, alphaOffset:Number=NaN) {
48 super();
49 if (tint || tint == 0) { //faster than !isNaN())
50 this.tint = uint(tint);
51 }
52 if (tintAmount || tintAmount == 0) {
53 this.tintAmount = tintAmount;
54 }
55 if (exposure || exposure == 0) {
56 this.exposure = exposure;
57 }
58 if (brightness || brightness == 0) {
59 this.brightness = brightness;
60 }
61 if (redMultiplier || redMultiplier == 0) {
62 this.redMultiplier = redMultiplier;
63 }
64 if (greenMultiplier || greenMultiplier == 0) {
65 this.greenMultiplier = greenMultiplier;
66 }
67 if (blueMultiplier || blueMultiplier == 0) {
68 this.blueMultiplier = blueMultiplier;
69 }
70 if (alphaMultiplier || alphaMultiplier == 0) {
71 this.alphaMultiplier = alphaMultiplier;
72 }
73 if (redOffset || redOffset == 0) {
74 this.redOffset = redOffset;
75 }
76 if (greenOffset || greenOffset == 0) {
77 this.greenOffset = greenOffset;
78 }
79 if (blueOffset || blueOffset == 0) {
80 this.blueOffset = blueOffset;
81 }
82 if (alphaOffset || alphaOffset == 0) {
83 this.alphaOffset = alphaOffset;
84 }
85 }
86
87 override protected function initEnumerables(nulls:Array, numbers:Array):void {
88 super.initEnumerables(nulls,
89 numbers.concat(["tintAmount","exposure","brightness","redMultiplier","redOffset",
90 "greenMultiplier","greenOffset","blueMultiplier","blueOffset",
91 "alphaMultiplier","alphaOffset"]));
92 }
93
94 public static function create(vars:Object):ColorTransformVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
95 if (vars is ColorTransformVars) {
96 return vars as ColorTransformVars;
97 }
98 return new ColorTransformVars(vars.tint,
99 vars.tintAmount,
100 vars.exposure,
101 vars.brightness,
102 vars.redMultiplier,
103 vars.greenMultiplier,
104 vars.blueMultiplier,
105 vars.alphaMultiplier,
106 vars.redOffset,
107 vars.greenOffset,
108 vars.blueOffset,
109 vars.alphaOffset);
110 }
111
112 //---- GETTERS / SETTERS ------------------------------------------------------------------------------
113
114 /** To change a DisplayObject's tint, set this to the hex value of the color you'd like the DisplayObject to end up at(or begin at if you're using TweenLite.from()). An example hex value would be 0xFF0000. If you'd like to remove the tint from a DisplayObject, use the removeTint special property. **/
115 public function get tint():uint {
116 return uint(_values.tint);
117 }
118 public function set tint(value:uint):void {
119 setProp("tint", value);
120 }
121
122
123 }
124 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.01
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in
8 the TweenLiteVars or TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {dropShadowFilter:{distance:5, blurX:10, blurY:10, color:0xFF0000}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 myVars.dropShadowFilter = new DropShadowFilterVars(5, 10, 10, 1, 45, 0xFF0000);
16 myVars.onComplete = myFunction;
17 TweenMax.to(my_mc, 1, myVars);
18
19
20 NOTES:
21 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel
22 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
23 - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly
24 data typed) syntax, like TweenMax.to(my_mc, 1, {dropShadowFilter:{blurX:"-5", blurY:"3"}});
25
26 AUTHOR: Jack Doyle, jack@greensock.com
27 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
28 */
29
30
31 package com.greensock.data {
32
33 public class DropShadowFilterVars extends BlurFilterVars {
34 public var distance:Number;
35 public var alpha:Number;
36 public var angle:Number;
37 public var strength:Number;
38
39 public function DropShadowFilterVars(distance:Number=4, blurX:Number=4, blurY:Number=4, alpha:Number=1, angle:Number=45, color:uint=0x000000, strength:Number=2, inner:Boolean=false, knockout:Boolean=false, hideObject:Boolean=false, quality:uint=2, remove:Boolean=false, index:int=-1, addFilter:Boolean=false) {
40 super(blurX, blurY, quality, remove, index, addFilter);
41 this.distance = distance;
42 this.alpha = alpha;
43 this.angle = angle;
44 this.color = color;
45 this.strength = strength;
46 this.inner = inner;
47 this.knockout = knockout;
48 this.hideObject = hideObject;
49 }
50
51 override protected function initEnumerables(nulls:Array, numbers:Array):void {
52 super.initEnumerables(nulls, numbers.concat(["distance","alpha","angle","strength"]));
53 }
54
55 public static function create(vars:Object):DropShadowFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
56 if (vars is DropShadowFilterVars) {
57 return vars as DropShadowFilterVars;
58 }
59 return new DropShadowFilterVars(vars.distance || 0,
60 vars.blurX || 0,
61 vars.blurY || 0,
62 vars.alpha || 0,
63 (vars.angle == null) ? 45 : vars.angle,
64 (vars.color == null) ? 0x000000 : vars.color,
65 (vars.strength == null) ? 2 : vars.strength,
66 Boolean(vars.inner),
67 Boolean(vars.knockout),
68 Boolean(vars.hideObject),
69 vars.quality || 2,
70 vars.remove || false,
71 (vars.index == null) ? -1 : vars.index,
72 vars.addFilter);
73 }
74
75 //---- GETTERS / SETTERS --------------------------------------------------------------------------------------------
76
77 /** Color. **/
78 public function get color():uint {
79 return uint(_values.color);
80 }
81 public function set color(value:uint):void {
82 setProp("color", value);
83 }
84
85 /** **/
86 public function get inner():Boolean {
87 return Boolean(_values.inner);
88 }
89 public function set inner(value:Boolean):void {
90 setProp("inner", value);
91 }
92
93 /** **/
94 public function get knockout():Boolean {
95 return Boolean(_values.knockout);
96 }
97 public function set knockout(value:Boolean):void {
98 setProp("knockout", value);
99 }
100
101 /** **/
102 public function get hideObject():Boolean {
103 return Boolean(_values.hideObject);
104 }
105 public function set hideObject(value:Boolean):void {
106 setProp("hideObject", value);
107 }
108
109 }
110
111 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.0
3 * DATE: 8/1/2009
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenLite.com
6 **/
7 package com.greensock.data {
8 import com.greensock.data.VarsCore;
9 /**
10 * This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
11 * strict data typing and code hinting (in most code editors). See the documentation in
12 * the TweenLiteVars or TweenMaxVars for more information.
13 *
14 * <b>Copyright 2010, 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.
15 *
16 * @author Jack Doyle, jack@greensock.com
17 */
18 dynamic public class FilterVars extends VarsCore {
19
20 public function FilterVars(remove:Boolean=false, index:int=-1, addFilter:Boolean=false) {
21 super();
22 this.remove = remove;
23 if (index > -1) {
24 this.index = index;
25 }
26 this.addFilter = addFilter;
27 }
28
29 //---- GETTERS / SETTERS -----------------------------------------------------------------------------------------
30
31 /** To remove the filter after the tween has completed, set remove to true. **/
32 public function get remove():Boolean {
33 return Boolean(_values.remove);
34 }
35 public function set remove(value:Boolean):void {
36 setProp("remove", value);
37 }
38
39 /** To force TweenLite/Max to create a new filter even if there's a filter of the same kind already applied to a DisplayObject, set addFilter to true. **/
40 public function get addFilter():Boolean {
41 return Boolean(_values.addFilter);
42 }
43 public function set addFilter(value:Boolean):void {
44 setProp("addFilter", value);
45 }
46
47 /** To define a particular index number in the target DisplayObject's filters Array for this filter, use index property. **/
48 public function get index():int {
49 return int(_values.index);
50 }
51 public function set index(value:int):void {
52 setProp("index", value);
53 }
54
55
56 }
57 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.01
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in
8 the TweenLiteVars, or TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {glowFilter:{blurX:10, blurY:10, color:0xFF0000}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 myVars.glowFilter = new GlowFilterVars(10, 10);
16 myVars.onComplete = myFunction;
17 TweenMax.to(my_mc, 1, myVars);
18
19
20 NOTES:
21 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel
22 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
23 - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly
24 data typed) syntax, like TweenMax.to(my_mc, 1, {glowFilter:{blurX:"-5", blurY:"3"}});
25
26 AUTHOR: Jack Doyle, jack@greensock.com
27 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
28 */
29
30
31 package com.greensock.data {
32
33 public class GlowFilterVars extends BlurFilterVars {
34 public var alpha:Number;
35 public var strength:Number;
36
37 public function GlowFilterVars(blurX:Number=10, blurY:Number=10, color:uint=0xFFFFFF, alpha:Number=1, strength:Number=2, inner:Boolean=false, knockout:Boolean=false, quality:uint=2, remove:Boolean=false, index:int=-1, addFilter:Boolean=false) {
38 super(blurX, blurY, quality, remove, index, addFilter);
39 this.color = color;
40 this.alpha = alpha;
41 this.strength = strength;
42 this.inner = inner;
43 this.knockout = knockout;
44 }
45
46 override protected function initEnumerables(nulls:Array, numbers:Array):void {
47 super.initEnumerables(nulls, numbers.concat(["alpha","strength"]));
48 }
49
50 public static function create(vars:Object):GlowFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
51 if (vars is GlowFilterVars) {
52 return vars as GlowFilterVars;
53 }
54 return new GlowFilterVars(vars.blurX || 0,
55 vars.blurY || 0,
56 (vars.color == null) ? 0x000000 : vars.color,
57 vars.alpha || 0,
58 (vars.strength == null) ? 2 : vars.strength,
59 Boolean(vars.inner),
60 Boolean(vars.knockout),
61 vars.quality || 2,
62 vars.remove || false,
63 (vars.index == null) ? -1 : vars.index,
64 vars.addFilter || false);
65 }
66
67 //---- GETTERS / SETTERS -------------------------------------------------------------------------------------
68
69 /** Color. **/
70 public function get color():uint {
71 return uint(_values.color);
72 }
73 public function set color(value:uint):void {
74 setProp("color", value);
75 }
76
77 /** **/
78 public function get inner():Boolean {
79 return Boolean(_values.inner);
80 }
81 public function set inner(value:Boolean):void {
82 setProp("inner", value);
83 }
84
85 /** **/
86 public function get knockout():Boolean {
87 return Boolean(_values.knockout);
88 }
89 public function set knockout(value:Boolean):void {
90 setProp("knockout", value);
91 }
92
93
94 }
95
96 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.0
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for transformAroundPoint tweens. See the documentation in
8 the TweenLiteVars or TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {transformAroundCenter:{scaleX:2, scaleY:1.5, rotation:30}}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 myVars.transformAroundPoint = new TransformAroundCenterVars(2, 1.5, 30);
16 myVars.onComplete = myFunction;
17 TweenMax.to(my_mc, 1, myVars);
18
19
20 NOTES:
21 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel
22 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
23 - You cannot define relative tween values with this utility.
24
25 AUTHOR: Jack Doyle, jack@greensock.com
26 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
27 */
28
29
30 package com.greensock.data {
31 import flash.geom.Point;
32
33 public class TransformAroundCenterVars extends TransformAroundPointVars {
34
35 public function TransformAroundCenterVars(scaleX:Number=NaN, scaleY:Number=NaN, rotation:Number=NaN, width:Number=NaN, height:Number=NaN, shortRotation:Object=null, x:Number=NaN, y:Number=NaN) {
36 super(null, scaleX, scaleY, rotation, width, height, shortRotation, x, y);
37 }
38
39 public static function create(vars:Object):TransformAroundCenterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
40 if (vars is TransformAroundCenterVars) {
41 return vars as TransformAroundCenterVars;
42 }
43 return new TransformAroundCenterVars(vars.scaleX,
44 vars.scaleY,
45 vars.rotation,
46 vars.width,
47 vars.height,
48 vars.shortRotation,
49 vars.x,
50 vars.y);
51 }
52
53 }
54 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 VERSION: 1.0
3 DATE: 1/29/2009
4 ACTIONSCRIPT VERSION: 3.0
5 DESCRIPTION:
6 This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant
7 strict data typing and code hinting (in most code editors) for transformAroundPoint tweens. See the documentation in
8 the TweenLiteVars or TweenMaxVars for more information.
9
10 USAGE:
11
12 Instead of TweenMax.to(my_mc, 1, {transformAroundPoint:{point:new Point(100, 50), scaleX:2, scaleY:1.5, rotation:30}}, onComplete:myFunction}), you could use this utility like:
13
14 var myVars:TweenMaxVars = new TweenMaxVars();
15 myVars.transformAroundPoint = new TransformAroundPointVars(new Point(100, 50), 2, 1.5, 30);
16 myVars.onComplete = myFunction;
17 TweenMax.to(my_mc, 1, myVars);
18
19
20 NOTES:
21 - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel
22 free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing.
23 - You cannot define relative tween values with this utility.
24
25 AUTHOR: Jack Doyle, jack@greensock.com
26 Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
27 */
28
29
30 package com.greensock.data {
31 import flash.geom.Point;
32
33 public class TransformAroundPointVars extends VarsCore {
34 public var point:Point;
35 public var scaleX:Number;
36 public var scaleY:Number;
37 public var scale:Number;
38 public var rotation:Number;
39 public var width:Number;
40 public var height:Number;
41 public var shortRotation:Object;
42 public var x:Number;
43 public var y:Number;
44
45 public function TransformAroundPointVars(point:Point=null, scaleX:Number=NaN, scaleY:Number=NaN, rotation:Number=NaN, width:Number=NaN, height:Number=NaN, shortRotation:Object=null, x:Number=NaN, y:Number=NaN) {
46 super();
47 if (point != null) {
48 this.point = point;
49 }
50 if (scaleX || scaleX == 0) { //faster than !isNaN())
51 this.scaleX = scaleX;
52 }
53 if (scaleY || scaleY == 0) {
54 this.scaleY = scaleY;
55 }
56 if (rotation || rotation == 0) {
57 this.rotation = rotation;
58 }
59 if (width || width == 0) {
60 this.width = width;
61 }
62 if (height || height == 0) {
63 this.height = height;
64 }
65 if (shortRotation != null) {
66 this.shortRotation = shortRotation;
67 }
68 if (x || x == 0) {
69 this.x = x;
70 }
71 if (y || y == 0) {
72 this.y = y;
73 }
74 }
75
76 override protected function initEnumerables(nulls:Array, numbers:Array):void {
77 super.initEnumerables(nulls.concat(["point","shortRotation"]), numbers.concat(["scaleX","scaleY","scale","rotation","width","height","x","y"]));
78 }
79
80 public static function create(vars:Object):TransformAroundPointVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor)
81 if (vars is TransformAroundPointVars) {
82 return vars as TransformAroundPointVars;
83 }
84 return new TransformAroundPointVars(vars.point,
85 vars.scaleX,
86 vars.scaleY,
87 vars.rotation,
88 vars.width,
89 vars.height,
90 vars.shortRotation,
91 vars.x,
92 vars.y);
93 }
94
95
96
97 }
98 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 4.0
3 * DATE: 8/3/2009
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenLite.com
6 **/
7 package com.greensock.data {
8 import com.greensock.data.TweenLiteVars;
9 /**
10 * There are 2 primary benefits of using this utility to define your TweenMax variables:
11 * <ol>
12 * <li> In most code editors, code hinting will be activated which helps remind you which special properties are available in TweenMax</li>
13 * <li> It allows you to code using strict datatyping (although it doesn't force you to). </li>
14 * </ol>
15 *
16 * <b>USAGE:</b><br /><br />
17 *
18 * Instead of TweenMax.to(my_mc, 1, {x:300, tint:0xFF0000, onComplete:myFunction}), you could use this utility like:<br /><br /><code>
19 *
20 * var myVars:TweenMaxVars = new TweenMaxVars();<br />
21 * myVars.addProp("x", 300); // use addProp() to add any property that doesn't already exist in the TweenMaxVars instance.<br />
22 * myVars.tint = 0xFF0000;<br />
23 * myVars.onComplete = myFunction;<br />
24 * TweenMax.to(my_mc, 1, myVars);<br /><br /></code>
25 *
26 *
27 * <b>NOTES:</b>
28 * <ul>
29 * <li> This class adds about 14 Kb to your published SWF.</li>
30 * <li> This utility is completely optional. If you prefer the shorter synatax in the regular TweenMax class, feel
31 * free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict datatyping.</li>
32 * <li> You may add custom properties to this class if you want, but in order to expose them to TweenMax, make sure
33 * you also add a getter and a setter that adds the property to the _exposedVars Object.</li>
34 * <li> You can reuse a single TweenMaxVars Object for multiple tweens if you want, but be aware that there are a few
35 * properties that must be handled in a special way, and once you set them, you cannot remove them. Those properties
36 * are: frame, visible, tint, and volume. If you are altering these values, it might be better to avoid reusing a TweenMaxVars
37 * Object.</li>
38 * </ul>
39 *
40 * <b>Copyright 2010, 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.
41 *
42 * @author Jack Doyle, jack@greensock.com
43 */
44 dynamic public class TweenMaxVars extends TweenLiteVars {
45 /** A function to which the TweenMax instance should dispatch a TweenEvent when it begins. This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.START, myFunction); **/
46 public var onStartListener:Function;
47 /** A function to which the TweenMax instance should dispatch a TweenEvent every time it updates values. This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.UPDATE, myFunction); **/
48 public var onUpdateListener:Function;
49 /** A function to which the TweenMax instance should dispatch a TweenEvent when it completes. This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.COMPLETE, myFunction); **/
50 public var onCompleteListener:Function;
51 /** A function that should be called when the tween has reached its starting point again after having been reversed **/
52 public var onReverseComplete : Function;
53 /** An Array of parameters to pass the onReverseComplete functions **/
54 public var onReverseCompleteParams : Array;
55 /** A function that should be called every time the tween repeats **/
56 public var onRepeat : Function;
57 /** An Array of parameters to pass the onRepeat function **/
58 public var onRepeatParams : Array;
59 /** Amount of time in seconds (or frames for frames-based tween) between repeats. **/
60 public var repeatDelay:Number;
61 /** Allows you to define the starting values for each property. Typically, TweenMax uses the current value (whatever it happens to be at the time the tween begins) as the start value, but startAt allows you to override that behavior. Simply pass an object in with whatever properties you'd liketo set just before the tween begins. For example, if mc.x is currently 100, and you'd like to tween it from 0 to 500, do TweenMax.to(mc, 2, {x:500, startAt:{x:0}}); **/
62 public var startAt:TweenLiteVars;
63 /** An Array of the names of properties that should be rounded to the nearest integer when tweening **/
64 public var roundProps:Array;
65
66 /**
67 * @param vars An Object containing properties that correspond to the properties you'd like to add to this TweenMaxVars Object. For example, TweenMaxVars({blurFilter:{blurX:10, blurY:20}, onComplete:myFunction})
68 */
69 public function TweenMaxVars(vars:Object=null) {
70 super(vars);
71 }
72
73 /** @private **/
74 override protected function initEnumerables(nulls:Array, numbers:Array):void {
75 super.initEnumerables(nulls.concat(["onStartListener","onUpdateListener","onReverseCompleteListener","onReverseCompleteParams",
76 "onRepeat","onRepeatParams","startAt","roundProps"]),
77 numbers.concat(["repeatDelay"]));
78 }
79
80 /** Clones the TweenMaxVars object. **/
81 override public function clone():TweenLiteVars {
82 return this.copyPropsTo(new TweenMaxVars()) as TweenMaxVars;
83 }
84
85
86 //---- GETTERS / SETTERS ---------------------------------------------------------------------------------------------
87
88 /** Works in conjunction with the repeat property, determining the behavior of each cycle. When yoyo is true, the tween will go back and forth, appearing to reverse every other cycle (this has no affect on the "reversed" property though). **/
89 public function get yoyo():Boolean {
90 return Boolean(_values.yoyo);
91 }
92 public function set yoyo(value:Boolean):void {
93 setProp("yoyo", value);
94 }
95
96 /** If true, the tween will be paused initially. **/
97 public function get paused():Boolean {
98 return Boolean(_values.paused);
99 }
100 public function set paused(value:Boolean):void {
101 setProp("paused", value);
102 }
103
104 /** If true, the tween will be reversed initially. This does not swap the starting/ending values in the tween - it literally changes its orientation/direction. Imagine the playhead moving backwards instead of forwards. **/
105 public function get reversed():Boolean {
106 return Boolean(_values.reversed);
107 }
108 public function set reversed(value:Boolean):void {
109 setProp("reversed", value);
110 }
111
112 /** Number of times that the tween should repeat (to repeat indefinitely, use -1). **/
113 public function get repeat():int {
114 return int(_values.repeat);
115 }
116 public function set repeat(value:int):void {
117 setProp("repeat", value);
118 }
119
120
121
122 }
123 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.01
3 * DATE: 9/23/2009
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenLite.com
6 **/
7 package com.greensock.data {
8 import flash.utils.Proxy;
9 import flash.utils.flash_proxy;
10 /**
11 * VarsCore provides a way to make an object's non-dynamic properties enumerable (only if/when the property is
12 * set to a non-default value) which is necessary for many of the vars objects in the GreenSock tweening
13 * platform (TweenLiteVars, TweenMaxVars, etc.). There is no reason to use VarsCore directly, but rather use
14 * a subclass like TweenLiteVars to enable strict data typing and code hinting in modern apps like Flex Builder, FDT, etc.
15 *
16 * <b>Copyright 2010, 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.
17 *
18 * @author Jack Doyle, jack@greensock.com
19 */
20 dynamic public class VarsCore extends Proxy {
21 /** @private (for backwards compatibility) **/
22 public const isTV:Boolean = true;
23 /** @private faster to use an already-created empty Array rather than keep re-creating them. **/
24 protected static const _empty:Array = [];
25
26 /** @private **/
27 protected var _numbers:Object = {};
28 /** @private **/
29 protected var _props:Array;
30 /** @private **/
31 protected var _values:Object = {};
32
33 /** Constructor **/
34 public function VarsCore() {
35 initEnumerables(_empty, _empty);
36 }
37
38 /** @private **/
39 protected function initEnumerables(nulls:Array, numbers:Array):void {
40 _props = nulls.concat(numbers);
41 var i:int = numbers.length;
42 while (i-- > 0) {
43 _numbers[numbers[i]] = true;
44 }
45 }
46
47 /** @private **/
48 flash_proxy override function getProperty(prop:*):* {
49 return _values[prop];
50 }
51
52 /** @private **/
53 flash_proxy override function setProperty(prop:*, value:*):void {
54 setProp(String(prop), value);
55 }
56
57 flash_proxy override function hasProperty(name:*):Boolean {
58 return name in _values;
59 }
60
61
62 /** @private **/
63 flash_proxy override function deleteProperty(prop:*):Boolean {
64 var i:int = _props.indexOf(prop);
65 if (i != -1) {
66 _props.splice(i, 1);
67 delete _values[prop];
68 return true;
69 } else {
70 return false;
71 }
72 }
73
74 /** @private **/
75 override flash_proxy function nextNameIndex(index:int):int {
76 if (index >= _props.length) {
77 return 0;
78 } else {
79 var l:int = _props.length;
80 var p:String;
81 for (var i:int = index; i < l; i++) {
82 p = _props[i];
83 if (_numbers[p]) {
84 if (this[p] || this[p] == 0) {
85 return i + 1;
86 }
87 } else if (this[p] != null) {
88 return i + 1;
89 }
90 }
91 return 0;
92 }
93 }
94
95 /** @private **/
96 override flash_proxy function nextName(index:int):String {
97 return _props[index - 1];
98 }
99
100 /** @private **/
101 protected function setProp(name:String, value:*):void {
102 if (!(name in _values)) {
103 _props[_props.length] = name;
104 }
105 _values[name] = value;
106 }
107
108 protected function copyPropsTo(vars:VarsCore):VarsCore {
109 for (var p:String in this) {
110 vars[p] = this[p];
111 }
112 return vars;
113 }
114
115
116
117 //---- GETTERS / SETTERS ------------------------------------------------------------------------
118
119 /** @private For backwards compatibility **/
120 public function get exposedVars():Object {
121 return this;
122 }
123
124
125 }
126 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2 public class Back {
3 public static function easeIn (t:Number, b:Number, c:Number, d:Number, s:Number = 1.70158):Number {
4 return c*(t/=d)*t*((s+1)*t - s) + b;
5 }
6 public static function easeOut (t:Number, b:Number, c:Number, d:Number, s:Number = 1.70158):Number {
7 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
8 }
9 public static function easeInOut (t:Number, b:Number, c:Number, d:Number, s:Number = 1.70158):Number {
10 if ((t/=d*0.5) < 1) return c*0.5*(t*t*(((s*=(1.525))+1)*t - s)) + b;
11 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
12 }
13 }
14 }
1 package com.greensock.easing {
2 public class Bounce {
3 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
4 if ((t/=d) < (1/2.75)) {
5 return c*(7.5625*t*t) + b;
6 } else if (t < (2/2.75)) {
7 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
8 } else if (t < (2.5/2.75)) {
9 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
10 } else {
11 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
12 }
13 }
14 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
15 return c - easeOut(d-t, 0, c, d) + b;
16 }
17 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
18 if (t < d*0.5) return easeIn (t*2, 0, c, d) * .5 + b;
19 else return easeOut (t*2-d, 0, c, d) * .5 + c*.5 + b;
20 }
21 }
22 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2 public class Circ {
3 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
4 return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
5 }
6 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
7 return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
8 }
9 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
10 if ((t/=d*0.5) < 1) return -c*0.5 * (Math.sqrt(1 - t*t) - 1) + b;
11 return c*0.5 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
12 }
13 }
14 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2
3 public class Cubic {
4 public static const power:uint = 2;
5
6 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
7 return c*(t/=d)*t*t + b;
8 }
9 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
10 return c*((t=t/d-1)*t*t + 1) + b;
11 }
12 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
13 if ((t/=d*0.5) < 1) return c*0.5*t*t*t + b;
14 return c*0.5*((t-=2)*t*t + 2) + b;
15 }
16 }
17 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2 /**
3 * EaseLookup enables you to find the easing function associated with a particular name (String),
4 * like "strongEaseOut" which can be useful when loading in XML data that comes in as Strings but
5 * needs to be translated to native function references.
6 *
7 * <b>Copyright 2010, 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.
8 *
9 * @author Jack Doyle, jack@greensock.com
10 */
11 public class EaseLookup {
12 /** @private **/
13 private static var _lookup:Object;
14
15 /**
16 * Finds the easing function associated with a particular name (String), like "strongEaseOut". This can be useful when
17 * loading in XML data that comes in as Strings but needs to be translated to native function references. You can pass in
18 * the name with or without the period, and it is case insensitive, so any of the following will find the Strong.easeOut function: <br /><br /><code>
19 * EaseLookup.find("Strong.easeOut") <br />
20 * EaseLookup.find("strongEaseOut") <br />
21 * EaseLookup.find("strongeaseout") <br /><br /></code>
22 *
23 * You can translate Strings directly when tweening, like this: <br /><code>
24 * TweenLite.to(mc, 1, {x:100, ease:EaseLookup.find(myString)});<br /><br /></code>
25 *
26 * @param name The name of the easing function, with or without the period and case insensitive (i.e. "Strong.easeOut" or "strongEaseOut")
27 * @return The easing function associated with the name
28 */
29 public static function find(name:String):Function {
30 if (_lookup == null) {
31 buildLookup();
32 }
33 return _lookup[name.toLowerCase()];
34 }
35
36 /** @private **/
37 private static function buildLookup():void {
38 _lookup = {};
39
40 addInOut(Back, ["back"]);
41 addInOut(Bounce, ["bounce"]);
42 addInOut(Circ, ["circ", "circular"]);
43 addInOut(Cubic, ["cubic"]);
44 addInOut(Elastic, ["elastic"]);
45 addInOut(Expo, ["expo", "exponential"]);
46 addInOut(Linear, ["linear"]);
47 addInOut(Quad, ["quad", "quadratic"]);
48 addInOut(Quart, ["quart","quartic"]);
49 addInOut(Quint, ["quint", "quintic", "strong"]);
50 addInOut(Sine, ["sine"]);
51
52 _lookup["linear.easenone"] = _lookup["lineareasenone"] = Linear.easeNone;
53 }
54
55 /** @private **/
56 private static function addInOut(easeClass:Class, names:Array):void {
57 var name:String;
58 var i:int = names.length;
59 while (i-- > 0) {
60 name = names[i].toLowerCase();
61 _lookup[name + ".easein"] = _lookup[name + "easein"] = easeClass.easeIn;
62 _lookup[name + ".easeout"] = _lookup[name + "easeout"] = easeClass.easeOut;
63 _lookup[name + ".easeinout"] = _lookup[name + "easeinout"] = easeClass.easeInOut;
64 }
65 }
66
67
68 }
69 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2 public class Elastic {
3 private static const _2PI:Number = Math.PI * 2;
4
5 public static function easeIn (t:Number, b:Number, c:Number, d:Number, a:Number = 0, p:Number = 0):Number {
6 var s:Number;
7 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
8 if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
9 else s = p/_2PI * Math.asin (c/a);
10 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*_2PI/p )) + b;
11 }
12 public static function easeOut (t:Number, b:Number, c:Number, d:Number, a:Number = 0, p:Number = 0):Number {
13 var s:Number;
14 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
15 if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
16 else s = p/_2PI * Math.asin (c/a);
17 return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*_2PI/p ) + c + b);
18 }
19 public static function easeInOut (t:Number, b:Number, c:Number, d:Number, a:Number = 0, p:Number = 0):Number {
20 var s:Number;
21 if (t==0) return b; if ((t/=d*0.5)==2) return b+c; if (!p) p=d*(.3*1.5);
22 if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
23 else s = p/_2PI * Math.asin (c/a);
24 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*_2PI/p )) + b;
25 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*_2PI/p )*.5 + c + b;
26 }
27 }
28 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2 public class Expo {
3 public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number {
4 return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b - c * 0.001;
5 }
6 public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number {
7 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
8 }
9 public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number {
10 if (t==0) return b;
11 if (t==d) return b+c;
12 if ((t/=d*0.5) < 1) return c*0.5 * Math.pow(2, 10 * (t - 1)) + b;
13 return c*0.5 * (-Math.pow(2, -10 * --t) + 2) + b;
14 }
15 }
16 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.0
3 * DATE: 10/18/2009
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com
6 **/
7 package com.greensock.easing {
8 import flash.utils.Dictionary;
9 import com.greensock.TweenLite;
10 /**
11 * TweenMax (AS3 only) has built-in algorithms that speed up the processing of certain easing equations but in order
12 * to take advantage of those optimizations, you must activate the easing equations first (you only need to
13 * activate them ONCE in your swf). The following easing equations from the com.greensock.easing package are
14 * eligible for activation:
15 * <code>
16 * <ul>
17 * <li>Linear (easeIn, easeOut, easeInOut, and easeNone)</li>
18 * <li>Quad (easeIn, easeOut, and easeInOut)</li>
19 * <li>Cubic (easeIn, easeOut, and easeInOut)</li>
20 * <li>Quart (easeIn, easeOut, and easeInOut)</li>
21 * <li>Quint (easeIn, easeOut, and easeInOut)</li>
22 * <li>Strong (easeIn, easeOut, and easeInOut)</li>
23 * </ul><br />
24 * </code>
25 *
26 * <b>EXAMPLE</b><br /><br />
27 *
28 * <code>
29 * import com.greensock.easing.*;<br /><br />
30 *
31 * //activate the optimized ease classes<br />
32 * FastEase.activate([Strong, Linear, Quad]);<br /><br />
33 *
34 * //then tween as usual (you don't have to do anything special in your tweens)<br />
35 * TweenMax.to(mc, 2, {x:200, ease:Linear.easeNone});<br /><br />
36 * </code>
37 *
38 * Once activated, the easing calculations run about <b>35-80% faster!</b> Keep in mind that the easing calculations are only one small part
39 * of the tweening engine, so you may only see a 2-15% improvement overall depending on the equation and quantity of simultaneous tweens.
40 *
41 * Notes: <br />
42 * <ul>
43 * <li>TweenLite does <b>NOT</b> have the internal algorithms in place to take advantage of optimized eases at this time (to conserve file size).</li>
44 * <li>Activating an ease multiple times doesn't hurt or help</li>
45 * </ul>
46 *
47 * @param easeClasses An Array containing the easing classes to activate, like [Strong, Linear, Quad]. It will automatically activate the easeIn, easeOut, easeInOut, and (if available) easeNone easing equations for each class in the Array.
48 */
49 public class FastEase {
50
51 /**
52 * Normally you should use the <code>FastEase.activate()</code> method to activate optimized eases, but if you
53 * want to activate an ease that is NOT in the com.greensock.easing package (for example
54 * <code>fl.motion.easing.Quadratic</code>), you can register individual easing equations with
55 * this method. For example:
56 *
57 * <code>
58 * import fl.motion.easing.Quadratic;<br />
59 * import com.greensock.easing.FastEase;<br /><br />
60 *
61 * FastEase.activateEase(Quadratic.easeIn, 1, 1);
62 * </code>
63 *
64 * @param ease The easing equation (function) to activate. For example, Quadratic.easeIn
65 * @param type The type of ease (in, out, or inOut) where easeIn is 1, easeOut is 2, and easeInOut is 3.
66 * @param power The magnitude or power of the ease. For example, Linear is 0, Quad is 1, Cubic is 2, Quart is 3 and Quint and Strong are 4.
67 */
68 public static function activateEase(ease:Function, type:int, power:uint):void {
69 TweenLite.fastEaseLookup[ease] = [type, power];
70 }
71
72 /**
73 * TweenMax (AS3 only) has built-in algorithms that speed up the processing of certain easing equations but in order
74 * to take advantage of those optimizations, you must activate the easing equations first (you only need to
75 * activate them ONCE in your swf). The following easing equations from the com.greensock.easing package are
76 * eligible for activation:
77 * <code>
78 * <ul>
79 * <li>Linear (easeIn, easeOut, easeInOut, and easeNone)</li>
80 * <li>Quad (easeIn, easeOut, and easeInOut)</li>
81 * <li>Cubic (easeIn, easeOut, and easeInOut)</li>
82 * <li>Quart (easeIn, easeOut, and easeInOut)</li>
83 * <li>Quint (easeIn, easeOut, and easeInOut)</li>
84 * <li>Strong (easeIn, easeOut, and easeInOut)</li>
85 * </ul><br />
86 * </code>
87 *
88 * <b>EXAMPLE</b><br /><br />
89 *
90 * <code>
91 * import com.greensock.easing.*;<br /><br />
92 *
93 * FastEase.activate([Strong, Linear, Quad]);<br /><br />
94 * </code>
95 *
96 * Notes: <br />
97 * <ul>
98 * <li>TweenLite does <b>NOT</b> have the internal algorithms in place to take advantage of optimized eases at this time (to conserve file size).</li>
99 * <li>Activating an ease multiple times doesn't hurt or help</li>
100 * </ul>
101 *
102 * @param easeClasses An Array containing the easing classes to activate, like [Strong, Linear, Quad]. It will automatically activate the easeIn, easeOut, easeInOut, and (if available) easeNone easing equations for each class in the Array.
103 */
104 public static function activate(easeClasses:Array):void {
105 var i:int = easeClasses.length, easeClass:Object;
106 while (i--) {
107 easeClass = easeClasses[i];
108 if (easeClass.hasOwnProperty("power")) {
109 activateEase(easeClass.easeIn, 1, easeClass.power);
110 activateEase(easeClass.easeOut, 2, easeClass.power);
111 activateEase(easeClass.easeInOut, 3, easeClass.power);
112 if (easeClass.hasOwnProperty("easeNone")) {
113 activateEase(easeClass.easeNone, 1, 0);
114 }
115 }
116 }
117 }
118
119 }
120 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2
3 public class Linear {
4 public static const power:uint = 0;
5
6 public static function easeNone (t:Number, b:Number, c:Number, d:Number):Number {
7 return c*t/d + b;
8 }
9 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
10 return c*t/d + b;
11 }
12 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
13 return c*t/d + b;
14 }
15 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
16 return c*t/d + b;
17 }
18 }
19 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2
3 public class Quad {
4 public static const power:uint = 1;
5
6 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
7 return c*(t/=d)*t + b;
8 }
9 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
10 return -c *(t/=d)*(t-2) + b;
11 }
12 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
13 if ((t/=d*0.5) < 1) return c*0.5*t*t + b;
14 return -c*0.5 * ((--t)*(t-2) - 1) + b;
15 }
16 }
17 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2
3 public class Quart {
4 public static const power:uint = 3;
5
6 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
7 return c*(t/=d)*t*t*t + b;
8 }
9 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
10 return -c * ((t=t/d-1)*t*t*t - 1) + b;
11 }
12 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
13 if ((t/=d*0.5) < 1) return c*0.5*t*t*t*t + b;
14 return -c*0.5 * ((t-=2)*t*t*t - 2) + b;
15 }
16 }
17 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2
3 public class Quint {
4 public static const power:uint = 4;
5
6 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
7 return c*(t/=d)*t*t*t*t + b;
8 }
9 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
10 return c*((t=t/d-1)*t*t*t*t + 1) + b;
11 }
12 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
13 if ((t/=d*0.5) < 1) return c*0.5*t*t*t*t*t + b;
14 return c*0.5*((t-=2)*t*t*t*t + 2) + b;
15 }
16 }
17 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.6
3 * DATE: 1/19/2010
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/roughease/
6 **/
7 package com.greensock.easing {
8 /**
9 * Most easing equations give a smooth, gradual transition between the start and end values, but RoughEase provides
10 * an easy way to get a rough, jagged effect instead. You can define an ease that it will use as a template (like a
11 * general guide - Linear.easeNone is the default) and then it will randomly plot points that wander from that template.
12 * The strength parameter controls how far from the template ease the points are allowed to go (a small number like
13 * 0.1 keeps it very close to the template ease whereas a larger number like 2 creates much larger jumps). You can
14 * also control the number of points in the ease, making it jerk more or less frequently. And lastly, you can associate
15 * a name with each RoughEase instance and retrieve it later like RoughEase.byName("myEaseName"). Since creating
16 * the initial RoughEase is the most processor-intensive part, it's a good idea to reuse instances if/when you can.<br /><br />
17 *
18 * <b>EXAMPLE CODE</b><br /><br /><code>
19 * import com.greensock.TweenLite;<br />
20 * import com.greensock.easing.RoughEase;<br /><br />
21 *
22 * TweenLite.from(mc, 3, {alpha:0, ease:RoughEase.create(1, 15)});<br /><br />
23 *
24 * //or create an instance directly<br />
25 * var rough:RoughEase = new RoughEase(1.5, 30, true, Strong.easeOut, "none", true, "superRoughEase");<br />
26 * TweenLite.to(mc, 3, {y:300, ease:rough.ease});<br /><br />
27 *
28 * //and later, you can find the ease by name like:<br />
29 * TweenLite.to(mc, 3, {y:300, ease:RoughEase.byName("superRoughEase")});
30 * </code><br /><br />
31 *
32 * <b>Copyright 2010, 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.
33 *
34 * @author Jack Doyle, jack@greensock.com
35 */
36 public class RoughEase {
37 /** @private **/
38 private static var _all:Object = {}; //keeps track of all instances so we can find them by name.
39 /** @private **/
40 private static var _count:uint = 0;
41
42 /** @private **/
43 private var _name:String;
44 /** @private **/
45 private var _first:EasePoint;
46 /** @private **/
47 private var _last:EasePoint;
48
49 /**
50 * Constructor
51 *
52 * @param strength amount of variance from the templateEase (Linear.easeNone by default) that each random point can be placed. A low number like 0.1 will hug very closely to the templateEase whereas a larger number like 2 will allow the values to wander further away from the templateEase.
53 * @param points quantity of random points to plot in the ease. A larger number will cause more (and quicker) flickering.
54 * @param restrictMaxAndMin If true, the ease will prevent random points from exceeding the end value or dropping below the starting value. For example, if you're tweening the x property from 0 to 100, the RoughEase would force all random points to stay between 0 and 100 if restrictMaxAndMin is true, but if it is false, a x could potentially jump above 100 or below 0 at some point during the tween (it would always end at 100 though).
55 * @param templateEase an easing equation that should be used as a template or guide. Then random points are plotted at a certain distance away from the templateEase (based on the strength parameter). The default is Linear.easeNone.
56 * @param taper to make the strength of the roughness taper towards the end or beginning, use "out" or "in" respectively here (default is "none") .
57 * @param randomize to randomize the placement of the points, set randomize to true (otherwise the points will zig-zag evenly across the ease)
58 * @param name a name to associate with the ease so that you can use RoughEase.byName() to look it up later. Of course you should always make sure you use a unique name for each ease (if you leave it blank, a name will automatically be generated).
59 */
60 public function RoughEase(strength:Number=1, points:uint=20, restrictMaxAndMin:Boolean=false, templateEase:Function=null, taper:String="none", randomize:Boolean=true, name:String="") {
61 if (name == "") {
62 _count++;
63 _name = "roughEase" + _count;
64 } else {
65 _name = name;
66 }
67 if (taper == "" || taper == null) {
68 taper = "none";
69 }
70 _all[_name] = this;
71 var a:Array = [];
72 var cnt:uint = 0;
73 var x:Number, y:Number, bump:Number, invX:Number, obj:Object;
74 var i:uint = points;
75 while (i--) {
76 x = randomize ? Math.random() : (1 / points) * i;
77 y = (templateEase != null) ? templateEase(x, 0, 1, 1) : x;
78 if (taper == "none") {
79 bump = 0.4 * strength;
80 } else if (taper == "out") {
81 invX = 1 - x;
82 bump = invX * invX * strength * 0.4;
83 } else {
84 bump = x * x * strength * 0.4;
85 }
86 if (randomize) {
87 y += (Math.random() * bump) - (bump * 0.5);
88 } else if (i % 2) {
89 y += bump * 0.5;
90 } else {
91 y -= bump * 0.5;
92 }
93 if (restrictMaxAndMin) {
94 if (y > 1) {
95 y = 1;
96 } else if (y < 0) {
97 y = 0;
98 }
99 }
100 a[cnt++] = {x:x, y:y};
101 }
102 a.sortOn("x", Array.NUMERIC);
103
104 _first = _last = new EasePoint(1, 1, null);
105
106 i = points;
107 while (i--) {
108 obj = a[i];
109 _first = new EasePoint(obj.x, obj.y, _first);
110 }
111 _first = new EasePoint(0, 0, _first);
112
113 }
114
115 /**
116 * This static function provides a quick way to create a RoughEase and immediately reference its ease function
117 * in a tween, like:<br /><br /><code>
118 *
119 * TweenLite.from(mc, 2, {alpha:0, ease:RoughEase.create(1.5, 15)});<br />
120 * </code>
121 *
122 * @param strength amount of variance from the templateEase (Linear.easeNone by default) that each random point can be placed. A low number like 0.1 will hug very closely to the templateEase whereas a larger number like 2 will allow the values to wander further away from the templateEase.
123 * @param points quantity of random points to plot in the ease. A larger number will cause more (and quicker) flickering.
124 * @param restrictMaxAndMin If true, the ease will prevent random points from exceeding the end value or dropping below the starting value. For example, if you're tweening the x property from 0 to 100, the RoughEase would force all random points to stay between 0 and 100 if restrictMaxAndMin is true, but if it is false, a x could potentially jump above 100 or below 0 at some point during the tween (it would always end at 100 though).
125 * @param templateEase an easing equation that should be used as a template or guide. Then random points are plotted at a certain distance away from the templateEase (based on the strength parameter). The default is Linear.easeNone.
126 * @param taper to make the strength of the roughness taper towards the end or beginning, use "out" or "in" respectively here (default is "none") .
127 * @param randomize to randomize the placement of the points, set randomize to true (otherwise the points will zig-zag evenly across the ease)
128 * @param name a name to associate with the ease so that you can use RoughEase.byName() to look it up later. Of course you should always make sure you use a unique name for each ease (if you leave it blank, a name will automatically be generated).
129 * @return easing function
130 */
131 public static function create(strength:Number=1, points:uint=20, restrictMaxAndMin:Boolean=false, templateEase:Function=null, taper:String="none", randomize:Boolean=true, name:String=""):Function {
132 return new RoughEase(strength, points, restrictMaxAndMin, templateEase, taper, randomize, name).ease;
133 }
134
135 /**
136 * Provides a quick way to look up a RoughEase by its name.
137 *
138 * @param name the name of the RoughEase
139 * @return easing function from the RoughEase associated with the name
140 */
141 public static function byName(name:String):Function {
142 return _all[name].ease;
143 }
144
145 /**
146 * Easing function that interpolates the numbers
147 *
148 * @param t time
149 * @param b start
150 * @param c change
151 * @param d duration
152 * @return Result of the ease
153 */
154 public function ease(t:Number, b:Number, c:Number, d:Number):Number {
155 var time:Number = t / d;
156 var p:EasePoint;
157 if (time < 0.5) {
158 p = _first;
159 while (p.time <= time) {
160 p = p.next;
161 }
162 p = p.prev;
163 } else {
164 p = _last;
165 while (p.time >= time) {
166 p = p.prev;
167 }
168 }
169 return b + (p.value + ((time - p.time) / p.gap) * p.change) * c;
170 }
171
172 /** name of the RoughEase instance **/
173 public function get name():String {
174 return _name;
175 }
176
177 public function set name(s:String):void {
178 delete _all[_name];
179 _name = s;
180 _all[s] = this;
181 }
182
183 }
184 }
185
186 internal class EasePoint {
187 public var time:Number;
188 public var gap:Number;
189 public var value:Number;
190 public var change:Number;
191 public var next:EasePoint;
192 public var prev:EasePoint;
193
194 public function EasePoint(time:Number, value:Number, next:EasePoint) {
195 this.time = time;
196 this.value = value;
197 if (next) {
198 this.next = next;
199 next.prev = this;
200 this.change = next.value - value;
201 this.gap = next.time - time;
202 }
203 }
204 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2 public class Sine {
3 private static const _HALF_PI:Number = Math.PI * 0.5;
4
5 public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number {
6 return -c * Math.cos(t/d * _HALF_PI) + c + b;
7 }
8 public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number {
9 return c * Math.sin(t/d * _HALF_PI) + b;
10 }
11 public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number {
12 return -c*0.5 * (Math.cos(Math.PI*t/d) - 1) + b;
13 }
14 }
15 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.easing {
2
3 public class Strong {
4 public static const power:uint = 4;
5
6 public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number {
7 return c*(t/=d)*t*t*t*t + b;
8 }
9 public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number {
10 return c*((t=t/d-1)*t*t*t*t + 1) + b;
11 }
12 public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number {
13 if ((t/=d*0.5) < 1) return c*0.5*t*t*t*t*t + b;
14 return c*0.5*((t-=2)*t*t*t*t + 2) + b;
15 }
16 }
17 }
1 This readme file applies to all eases in this directory EXCEPT the CustomEase, EaseLookup, FastEase, and RoughEase.
2
3 ============================================================================================
4 Easing Equations
5 (c) 2003 Robert Penner, all rights reserved.
6 This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html.
7 ============================================================================================
8
9 TERMS OF USE - EASING EQUATIONS
10
11 Open source under the BSD License.
12
13 All rights reserved.
14
15 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
16
17 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
19 * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.2
3 * DATE: 2010-07-28
4 * AS3
5 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/
6 **/
7 package com.greensock.events {
8
9 import flash.events.Event;
10 /**
11 * An Event dispatched by one of the loaders in the LoaderMax system.
12 * <br /><br />
13 *
14 * <b>Copyright 2010, 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.
15 *
16 * @author Jack Doyle, jack@greensock.com
17 */
18 public class LoaderEvent extends Event {
19 /** Dispatched by a LoaderMax (or other loader that may dynamically recognize nested loaders like XMLLoader and SWFLoader) when one of its children begins loading. **/
20 public static const CHILD_OPEN:String="childOpen";
21 /** Dispatched by a LoaderMax (or other loader that may dynamically recognize nested loaders like XMLLoader and SWFLoader) when one of its children dispatches a <code>PROGRESS</code> Event. **/
22 public static const CHILD_PROGRESS:String="childProgress";
23 /** Dispatched by a LoaderMax (or other loader that may dynamically recognize nested loaders like XMLLoader and SWFLoader) when one of its children aborts its loading. This can happen when the loader fails, when <code>cancel()</code> is manually called, or when another loader is prioritized in the loading queue. **/
24 public static const CHILD_CANCEL:String="childCancel";
25 /** Dispatched by a LoaderMax (or other loader that may dynamically recognize nested loaders like XMLLoader and SWFLoader) when one of its children finishes loading. **/
26 public static const CHILD_COMPLETE:String="childComplete";
27 /** Dispatched by a LoaderMax (or other loader that may dynamically recognize nested loaders like XMLLoader and SWFLoader) when one of its children fails to load. **/
28 public static const CHILD_FAIL:String="childFail";
29 /** Dispatched when the loader begins loading, like when its <code>load()</code> method is called. **/
30 public static const OPEN:String="open";
31 /** Dispatched when the loader's <code>bytesLoaded</code> changes. **/
32 public static const PROGRESS:String="progress";
33 /** Dispatched when the loader aborts its loading. This can happen when the loader fails, when <code>cancel()</code> is manually called, or when another loader is prioritized in the loading queue. **/
34 public static const CANCEL:String="cancel";
35 /** Dispatched when the loader fails. **/
36 public static const FAIL:String="fail";
37 /** Dispatched when the loader initializes which means different things for different loaders. For example, a SWFLoader dispatches <code>INIT</code> when it downloads enough of the swf to render the first frame. When a VideoLoader receives MetaData, it dispatches its <code>INIT</code> event, as does an MP3Loader when it receives ID3 data. See the docs for each class for specifics. **/
38 public static const INIT:String="init";
39 /** Dispatched when the loader finishes loading. **/
40 public static const COMPLETE:String="complete";
41 /** Dispatched when the loader (or one of its children) receives an HTTP_STATUS event (see Adobe docs for specifics). **/
42 public static const HTTP_STATUS:String="httpStatus";
43 /** When script access is denied for a particular loader (like if an ImageLoader or SWFLoader tries loading from another domain and the crossdomain.xml file is missing or doesn't grant permission properly), a SCRIPT_ACCESS_DENIED LoaderEvent will be dispatched. **/
44 public static const SCRIPT_ACCESS_DENIED:String="scriptAccessDenied";
45 /** Dispatched when the loader (or one of its children) throws any error, like an IO_ERROR or SECURITY_ERROR. **/
46 public static const ERROR:String="error";
47 /** Dispatched when the the loader (or one of its children) encounters an IO_ERROR (typically when it cannot find the file at the specified <code>url</code>). **/
48 public static const IO_ERROR:String="ioError";
49 /** Dispatched when the loader (or one of its children) encounters a SECURITY_ERROR (see Adobe's docs for details). **/
50 public static const SECURITY_ERROR:String="securityError";
51
52 /** @private **/
53 protected var _target:Object;
54 /** @private **/
55 protected var _ready:Boolean;
56
57 /** For <code>ERROR, FAIL</code>, and <code>CHILD_FAIL</code> events, this text will give more details about the error or failure. **/
58 public var text:String;
59 /** Event-related data which varies based on the type of event. For example, VideoLoader dispatches a VIDEO_CUE_POINT event containing data about the cue point. **/
60 public var data:*;
61
62 /**
63 * Constructor
64 *
65 * @param type Type of event
66 * @param target Target
67 * @param text Error text (if any)
68 */
69 public function LoaderEvent(type:String, target:Object, text:String="", data:*=null){
70 super(type, false, false);
71 _target = target;
72 this.text = text;
73 this.data = data;
74 }
75
76 /** @inheritDoc **/
77 public override function clone():Event{
78 return new LoaderEvent(this.type, _target, this.text, this.data);
79 }
80
81 /**
82 * The loader associated with the LoaderEvent. This may be different than the <code>currentTarget</code>.
83 * The <code>target</code> always refers to the originating loader, so if there is an ImageLoader nested inside
84 * a LoaderMax instance and you add an event listener to the LoaderMax, if the ImageLoader dispatches an error
85 * event, the event's <code>target</code> will refer to the ImageLoader whereas the <code>currentTarget</code> will
86 * refer to the LoaderMax instance that is currently processing the event.
87 **/
88 override public function get target():Object {
89 if (_ready) {
90 return _target;
91 } else {
92 //when the event is re-dispatched, Flash's event system checks to see if the target has been set and if it has, Flash will clone() and reset the target so we need to report the target as null the first time and then on subsequent calls, report the real target.
93 _ready = true;
94 }
95 return null;
96 }
97
98 }
99
100 }
...\ No newline at end of file ...\ No newline at end of file
1 package com.greensock.events {
2 import flash.events.Event;
3 /**
4 * Used for dispatching events from the GreenSock Tweening Platform. <br /><br />
5 *
6 * <b>Copyright 2010, 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.
7 *
8 * @author Jack Doyle, jack@greensock.com
9 */
10 public class TweenEvent extends Event {
11 /** @private **/
12 public static const VERSION:Number = 1.1;
13 public static const START:String = "start";
14 public static const UPDATE:String = "change";
15 public static const COMPLETE:String = "complete";
16 public static const REVERSE_COMPLETE:String = "reverseComplete";
17 public static const REPEAT:String = "repeat";
18 public static const INIT:String = "init";
19
20 public function TweenEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) {
21 super(type, bubbles, cancelable);
22 }
23
24 public override function clone():Event {
25 return new TweenEvent(this.type, this.bubbles, this.cancelable);
26 }
27
28 }
29
30 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.01
3 * DATE: 2010-02-03
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://blog.greensock.com/
6 **/
7 package com.greensock.layout {
8 /**
9 * Provides constants for defining the alignment of objects. <br /><br />
10 *
11 * <b>Copyright 2010, 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.
12 *
13 * @author Jack Doyle, jack@greensock.com
14 */
15 public class AlignMode {
16
17 /** Align with the top of the area. **/
18 public static const TOP:String = "top";
19 /** Align with the center of the area. **/
20 public static const CENTER:String = "center";
21 /** Align with the right side of the area. **/
22 public static const RIGHT:String = "right";
23 /** Align with the left side of the area. **/
24 public static const LEFT:String = "left";
25 /** Align with the bottom of the area. **/
26 public static const BOTTOM:String = "bottom";
27
28 }
29 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.04
3 * DATE: 2010-03-06
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://blog.greensock.com/
6 **/
7 package com.greensock.layout {
8 /**
9 * Provides constants for defining how objects should scale/stretch to fit within an area (like a <code>LiquidArea</code> or <code>AutoFitArea</code>). <br /><br />
10 *
11 * <b>Copyright 2010, 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.
12 *
13 * @author Jack Doyle, jack@greensock.com
14 */
15 public class ScaleMode {
16
17 /** Stretches the object to fill the area completely in terms of both width and height. This mode does <b>NOT</b> concern itself with preserving the object's original aspect ratio (proportions). **/
18 public static const STRETCH:String = "stretch";
19 /** Stretches the object's width to fill the area horizontally, but does not affect its height **/
20 public static const WIDTH_ONLY:String = "widthOnly";
21 /** Stretches the object's height to fill the area vertically, but does not affect its width **/
22 public static const HEIGHT_ONLY:String = "heightOnly";
23 /** Scales the object proportionally to completely fill the area, allowing portions of it to exceed the bounds when its aspect ratio doesn't match the area's. For example, if the area is 100x50 and the DisplayObject is natively 200x200, it will scale it down to 100x100 meaning it will exceed the bounds of the area vertically. **/
24 public static const PROPORTIONAL_OUTSIDE:String = "proportionalOutside";
25 /** Scales the object proportionally to fit inside the area (its edges will never exceed the bounds of the area). For example, if the area is 100x50 and the DisplayObject is natively 200x200, it will scale it down to 50x50 meaning it will not fill the area horizontally, but it will vertically. **/
26 public static const PROPORTIONAL_INSIDE:String = "proportionalInside";
27 /** Does not scale the object at all **/
28 public static const NONE:String = "none";
29
30 }
31 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.0
3 * DATE: 2010-06-16
4 * AS3
5 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/
6 **/
7 package com.greensock.loading {
8 /**
9 * Defines status values for loaders. <br /><br />
10 *
11 * <b>Copyright 2010, 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.
12 *
13 * @author Jack Doyle, jack@greensock.com
14 */
15 public class LoaderStatus {
16
17 /** The loader is ready to load and has not completed yet. **/
18 public static const READY:int = 0;
19 /** The loader is actively in the process of loading. **/
20 public static const LOADING:int = 1;
21 /** The loader has completed. **/
22 public static const COMPLETED:int = 2;
23 /** The loader is paused. **/
24 public static const PAUSED:int = 3;
25 /** The loader failed and did not load properly. **/
26 public static const FAILED:int = 4;
27 /** The loader has been disposed. **/
28 public static const DISPOSED:int = 5;
29
30 }
31
32 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.3
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/
6 **/
7 package com.greensock.loading {
8 import com.greensock.loading.core.LoaderItem;
9
10 import flash.display.DisplayObject;
11 import flash.display.LoaderInfo;
12 import flash.events.Event;
13 import flash.events.ProgressEvent;
14 /**
15 * Tracks the loading progress of the swf in which the loader resides (basically a simple tool for tracking
16 * the <code>loaderInfo</code>'s progress). SelfLoader is only useful in situations where you want to factor
17 * the current swf's loading progress into a LoaderMax queue or maybe display a progress bar for the current
18 * swf or fire an event when loading has finished.<br /><br />
19 *
20 * <strong>OPTIONAL VARS PROPERTIES</strong><br />
21 * The following special properties can be passed into the SelfLoader constructor via its <code>vars</code> parameter:<br />
22 * <ul>
23 * <li><strong> name : String</strong> - A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".</li>
24 * <li><strong> autoDispose : Boolean</strong> - When <code>autoDispose</code> is <code>true</code>, the loader will be disposed immediately after it completes (it calls the <code>dispose()</code> method internally after dispatching its <code>COMPLETE</code> event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError). Once a loader is disposed, it can no longer be found with <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code>. The default <code>autoDispose</code> value is <code>false</code>.
25 *
26 * <br /><br />----EVENT HANDLER SHORTCUTS----</li>
27 * <li><strong> onProgress : Function</strong> - A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.</li>
28 * <li><strong> onComplete : Function</strong> - A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).</li>
29 * </ul><br />
30 *
31 * @example Example AS3 code:<listing version="3.0">
32 import com.greensock.loading.~~;
33 import com.greensock.events.LoaderEvent;
34
35 //create a SelfLoader
36 var loader:SelfLoader = new SelfLoader(this, {name:"self", onProgress:progressHandler, onComplete:completeHandler});
37
38 //Or you could put the SelfLoader into a LoaderMax. Create one first...
39 var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
40
41 //append the SelfLoader and several other loaders
42 queue.append( loader );
43 queue.append( new ImageLoader("images/photo1.jpg", {name:"photo1", container:this}) );
44 queue.append( new SWFLoader("swf/child.swf", {name:"child", container:this, x:100, estimatedBytes:3500}) );
45
46 //start loading the LoaderMax queue
47 queue.load();
48
49 function progressHandler(event:LoaderEvent):void {
50 trace("progress: " + event.target.progress);
51 }
52
53 function completeHandler(event:LoaderEvent):void {
54 trace(event.target + " complete");
55 }
56
57 function errorHandler(event:LoaderEvent):void {
58 trace("error occured with " + event.target + ": " + event.text);
59 }
60 </listing>
61 *
62 * <b>Copyright 2010, 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.
63 *
64 * @author Jack Doyle, jack@greensock.com
65 */
66 public class SelfLoader extends LoaderItem {
67 /** @private **/
68 protected var _loaderInfo:LoaderInfo;
69
70 /**
71 * Constructor
72 *
73 * @param self A DisplayObject from the main swf (it will use this DisplayObject's <code>loaderInfo</code> to track the loading progress).
74 * @param vars An object containing optional configuration details. For example: <code>new SelfLoader(this, {name:"self", onComplete:completeHandler, onProgress:progressHandler})</code>.<br /><br />
75 *
76 * The following special properties can be passed into the constructor via the <code>vars</code> parameter:<br />
77 * <ul>
78 * <li><strong> name : String</strong> - A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".</li>
79 * <li><strong> autoDispose : Boolean</strong> - When <code>autoDispose</code> is <code>true</code>, the loader will be disposed immediately after it completes (it calls the <code>dispose()</code> method internally after dispatching its <code>COMPLETE</code> event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError). Once a loader is disposed, it can no longer be found with <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code>. The default <code>autoDispose</code> value is <code>false</code>.
80 *
81 * <br /><br />----EVENT HANDLER SHORTCUTS----</li>
82 * <li><strong> onProgress : Function</strong> - A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.</li>
83 * <li><strong> onComplete : Function</strong> - A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).</li>
84 * </ul>
85 */
86 public function SelfLoader(self:DisplayObject, vars:Object=null) {
87 super(self.loaderInfo.url, vars);
88 _type = "SelfLoader";
89 _loaderInfo = self.loaderInfo;
90 _loaderInfo.addEventListener(ProgressEvent.PROGRESS, _progressHandler, false, 0, true);
91 _loaderInfo.addEventListener(Event.COMPLETE, _completeHandler, false, 0, true);
92 _cachedBytesTotal = _loaderInfo.bytesTotal;
93 _cachedBytesLoaded = _loaderInfo.bytesLoaded;
94 _status = LoaderStatus.LOADING;
95 _auditedSize = true;
96 _content = self;
97 }
98
99 /** @private scrubLevel: 0 = cancel, 1 = unload, 2 = dispose, 3 = flush **/
100 override protected function _dump(scrubLevel:int=0, newStatus:int=0, suppressEvents:Boolean=false):void {
101 if (scrubLevel >= 2) {
102 _loaderInfo.removeEventListener(ProgressEvent.PROGRESS, _progressHandler);
103 _loaderInfo.removeEventListener(Event.COMPLETE, _completeHandler);
104 }
105 super._dump(scrubLevel, newStatus, suppressEvents);
106 }
107
108 }
109 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.3
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/
6 **/
7 package com.greensock.loading.core {
8 import com.greensock.events.LoaderEvent;
9 import com.greensock.loading.LoaderStatus;
10
11 import flash.events.Event;
12 import flash.events.ProgressEvent;
13 import flash.net.URLRequest;
14 import flash.net.URLStream;
15
16 /** Dispatched when the loader experiences an IO_ERROR while loading or auditing its size. **/
17 [Event(name="ioError", type="com.greensock.events.LoaderEvent")]
18 /**
19 * Serves as the base class for all individual loaders (not LoaderMax) like <code>ImageLoader,
20 * XMLLoader, SWFLoader, MP3Loader</code>, etc. There is no reason to use this class on its own.
21 * Please see the documentation for the other classes.
22 * <br /><br />
23 *
24 * <b>Copyright 2010, 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.
25 *
26 * @author Jack Doyle, jack@greensock.com
27 */
28 public class LoaderItem extends LoaderCore {
29 /** @private **/
30 protected static var _cacheID:uint = uint(Math.random() * 100000000) * int(Math.random() * 1000);
31
32 /** @private **/
33 protected var _url:String;
34 /** @private **/
35 protected var _request:URLRequest;
36 /** @private **/
37 protected var _scriptAccessDenied:Boolean;
38 /** @private used in auditSize() just to preload enough of the file to determine bytesTotal. **/
39 protected var _auditStream:URLStream;
40 /** @private For certain types of loaders like SWFLoader and XMLLoader where there may be nested loaders found, it's better to prioritize the estimatedBytes if one is defined. Otherwise, the file size will be used which may be MUCH smaller than all the assets inside of it (like an XML file with a bunch of VideoLoaders).**/
41 protected var _preferEstimatedBytesInAudit:Boolean;
42 /** @private **/
43 protected var _httpStatus:int;
44
45 /**
46 * Constructor
47 *
48 * @param urlOrRequest The url (<code>String</code>) or <code>URLRequest</code> from which the loader should get its content
49 * @param vars An object containing optional parameters like <code>estimatedBytes, name, autoDispose, onComplete, onProgress, onError</code>, etc. For example, <code>{estimatedBytes:2400, name:"myImage1", onComplete:completeHandler}</code>.
50 */
51 public function LoaderItem(urlOrRequest:*, vars:Object=null) {
52 super(vars);
53 _request = (urlOrRequest is URLRequest) ? urlOrRequest as URLRequest : new URLRequest(urlOrRequest);
54 _url = _request.url;
55 }
56
57 /** @private **/
58 protected function _prepRequest():void {
59 _scriptAccessDenied = false;
60 _httpStatus = 0;
61 _closeStream();
62 if (this.vars.noCache && (!_isLocal || _url.substr(0, 4) == "http")) {
63 _request.url = _url + ((_url.indexOf("?") == -1) ? "?" : "&") + "cacheBusterID=" + (_cacheID++);
64 }
65 }
66
67 /** @private scrubLevel: 0 = cancel, 1 = unload, 2 = dispose, 3 = flush **/
68 override protected function _dump(scrubLevel:int=0, newStatus:int=0, suppressEvents:Boolean=false):void {
69 _closeStream();
70 super._dump(scrubLevel, newStatus, suppressEvents);
71 }
72
73 /** @inheritDoc **/
74 override public function auditSize():void {
75 if (_auditStream == null) {
76 _auditStream = new URLStream();
77 _auditStream.addEventListener(ProgressEvent.PROGRESS, _auditStreamHandler, false, 0, true);
78 _auditStream.addEventListener(Event.COMPLETE, _auditStreamHandler, false, 0, true);
79 _auditStream.addEventListener("ioError", _auditStreamHandler, false, 0, true);
80 _auditStream.addEventListener("securityError", _auditStreamHandler, false, 0, true);
81 _auditStream.load(_request);
82 }
83 }
84
85 /** @private **/
86 protected function _closeStream():void {
87 if (_auditStream != null) {
88 _auditStream.removeEventListener(ProgressEvent.PROGRESS, _auditStreamHandler);
89 _auditStream.removeEventListener(Event.COMPLETE, _auditStreamHandler);
90 _auditStream.removeEventListener("ioError", _auditStreamHandler);
91 _auditStream.removeEventListener("securityError", _auditStreamHandler);
92 try {
93 _auditStream.close();
94 } catch (error:Error) {
95
96 }
97 _auditStream = null;
98 }
99 }
100
101 //---- EVENT HANDLERS ------------------------------------------------------------------------------------
102
103 /** @private **/
104 protected function _auditStreamHandler(event:Event):void {
105 if (event is ProgressEvent) {
106 _cachedBytesTotal = (event as ProgressEvent).bytesTotal;
107 if (_preferEstimatedBytesInAudit && uint(this.vars.estimatedBytes) > _cachedBytesTotal) {
108 _cachedBytesTotal = uint(this.vars.estimatedBytes);
109 }
110 } else if (event.type == "ioError" || event.type == "securityError") {
111 if (this.vars.alternateURL != undefined && this.vars.alternateURL != "" && _url != this.vars.alternateURL) {
112 _url = _request.url = this.vars.alternateURL;
113 _auditStream.load(_request);
114 _errorHandler(event);
115 return;
116 } else {
117 //note: a CANCEL event won't be dispatched because technically the loader wasn't officially loading - we were only briefly checking the bytesTotal with a NetStream.
118 super._failHandler(event);
119 }
120 }
121 _auditedSize = true;
122 _closeStream();
123 dispatchEvent(new Event("auditedSize"));
124 }
125
126 /** @private **/
127 override protected function _failHandler(event:Event):void {
128 if (this.vars.alternateURL != undefined && this.vars.alternateURL != "" && _url != this.vars.alternateURL) {
129 this.url = this.vars.alternateURL; //also calls _load()
130 _errorHandler(event);
131 } else {
132 super._failHandler(event);
133 }
134 }
135
136
137 /** @private **/
138 protected function _httpStatusHandler(event:Event):void {
139 _httpStatus = (event as Object).status;
140 dispatchEvent(new LoaderEvent(LoaderEvent.HTTP_STATUS, this));
141 }
142
143
144 //---- GETTERS / SETTERS -------------------------------------------------------------------------
145
146 /** The url from which the loader should get its content. **/
147 public function get url():String {
148 return _url;
149 }
150 public function set url(value:String):void {
151 if (_url != value) {
152 _url = _request.url = value;
153 var isLoading:Boolean = Boolean(_status == LoaderStatus.LOADING);
154 _dump(0, LoaderStatus.READY, true);
155 if (isLoading) {
156 _load();
157 }
158 }
159 }
160
161 /** The <code>URLRequest</code> associated with the loader. **/
162 public function get request():URLRequest {
163 return _request;
164 }
165
166 /** The httpStatus code of the loader. You may listen for <code>LoaderEvent.HTTP_STATUS</code> events on certain types of loaders to be notified when it changes, but in some environments the Flash player cannot sense httpStatus codes in which case the value will remain <code>0</code>. **/
167 public function get httpStatus():int {
168 return _httpStatus;
169 }
170
171 /**
172 * If the loaded content is denied script access (because of security sandbox restrictions,
173 * a missing crossdomain.xml file, etc.), <code>scriptAccessDenied</code> will be set to <code>true</code>.
174 * In the case of loaded images or swf files, this means that you should not attempt to perform
175 * BitmapData operations on the content. An image's <code>smoothing</code> property cannot be set
176 * to <code>true</code> either. Even if script access is denied for particular content, LoaderMax will still
177 * attempt to load it.
178 **/
179 public function get scriptAccessDenied():Boolean {
180 return _scriptAccessDenied;
181 }
182
183 }
184 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data {
8 import com.greensock.loading.data.core.LoaderItemVars;
9 import flash.display.DisplayObject;
10 /**
11 * Can be used instead of a generic object to define the <code>vars</code> parameter of a CSSLoader's constructor. <br /><br />
12 *
13 * There are 2 primary benefits of using a CSSLoaderVars instance to define your CSSLoader variables:
14 * <ol>
15 * <li> In most code editors, code hinting will be activated which helps remind you which special properties are available in CSSLoader</li>
16 * <li> It enables strict data typing for improved debugging (ensuring, for example, that you don't define a Boolean value for <code>onComplete</code> where a Function is expected).</li>
17 * </ol>
18 *
19 * <strong>USAGE:</strong><br /><br />
20 *
21 * Instead of <code>new CSSLoader("styles.css", {name:"css", estimatedBytes:1500, onComplete:completeHandler, onProgress:progressHandler})</code>,
22 * you could use this utility like:<br /><br /><code>
23 *
24 * var vars:CSSLoaderVars = new CSSLoaderVars();<br />
25 * vars.name = "css";<br />
26 * vars.estimatedBytes = 1500;<br />
27 * vars.onComplete = completeHandler;<br />
28 * vars.onProgress = progressHandler;<br />
29 * var loader:CSSLoader = new CSSLoader("styles.css", vars);<br /><br /></code>
30 *
31 * Some of the most common properties can be defined directly in the constructor like this:<br /><br /><code>
32 *
33 * var loader:CSSLoader = new CSSLoader("styles.css", new CSSLoaderVars("css", 1500, completeHandler, progressHandler) );<br /><br /></code>
34 *
35 * <strong>NOTE:</strong> Using CSSLoaderVars is completely optional. If you prefer the shorter synatax with the generic Object, feel
36 * free to use it. The purpose of this class is simply to enable code hinting and to allow for strict data typing. <br /><br />
37 *
38 * <b>Copyright 2010, 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.
39 *
40 * @author Jack Doyle, jack@greensock.com
41 */
42 dynamic public class CSSLoaderVars extends LoaderItemVars {
43
44 /**
45 * Constructor
46 *
47 * @param name A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".
48 * @param estimatedBytes Initially, the loader's <code>bytesTotal</code> is set to the <code>estimatedBytes</code> value (or <code>LoaderMax.defaultEstimatedBytes</code> if one isn't defined). Then, when the loader begins loading and it can accurately determine the bytesTotal, it will do so. Setting <code>estimatedBytes</code> is optional, but the more accurate the value, the more accurate your loaders' overall progress will be initially. If the loader is inserted into a LoaderMax instance (for queue management), its <code>auditSize</code> feature can attempt to automatically determine the <code>bytesTotal</code> at runtime (there is a slight performance penalty for this, however - see LoaderMax's documentation for details).
49 * @param onComplete A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
50 * @param onProgress A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.
51 * @param onFail A handler function for <code>LoaderEvent.FAIL</code> events which are dispatched whenever the loader fails and its <code>status</code> changes to <code>LoaderStatus.FAILED</code>. Make sure your onFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
52 * @param noCache If <code>true</code>, a "cacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> by <code>url</code> or when you're running locally).
53 * @param alternateURL If you define an <code>alternateURL</code>, the loader will initially try to load from its original <code>url</code> and if it fails, it will automatically (and permanently) change the loader's <code>url</code> to the <code>alternateURL</code> and try again. Think of it as a fallback or backup <code>url</code>. It is perfectly acceptable to use the same <code>alternateURL</code> for multiple loaders (maybe a default image for various ImageLoaders for example).
54 * @param requireWithRoot LoaderMax supports <i>subloading</i>, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this loader as part of its parent SWFLoader's progress, you must set the <code>requireWithRoot</code> property to your swf's <code>root</code>. For example, <code>vars.requireWithRoot = this.root;</code>.
55 */
56 public function CSSLoaderVars(name:String="",
57 estimatedBytes:uint=0,
58 onComplete:Function=null,
59 onProgress:Function=null,
60 onFail:Function=null,
61 noCache:Boolean=false,
62 alternateURL:String="",
63 requireWithRoot:DisplayObject=null) {
64 super(name, estimatedBytes, onComplete, onProgress, onFail, noCache, alternateURL, requireWithRoot);
65 }
66
67 /** Clones the object. **/
68 public function clone():CSSLoaderVars {
69 return _cloneProps(new CSSLoaderVars()) as CSSLoaderVars;
70 }
71
72 }
73 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data {
8 import com.greensock.loading.core.LoaderCore;
9 import com.greensock.loading.data.core.LoaderItemVars;
10
11 import flash.display.DisplayObject;
12 /**
13 * Can be used instead of a generic object to define the <code>vars</code> parameter of a DataLoader's constructor. <br /><br />
14 *
15 * There are 2 primary benefits of using a DataLoaderVars instance to define your DataLoader variables:
16 * <ol>
17 * <li> In most code editors, code hinting will be activated which helps remind you which special properties are available in DataLoader</li>
18 * <li> It enables strict data typing for improved debugging (ensuring, for example, that you don't define a Boolean value for <code>onComplete</code> where a Function is expected).</li>
19 * </ol>
20 *
21 * <strong>USAGE:</strong><br /><br />
22 *
23 * Instead of <code>new DataLoader("getData.php", {name:"myData", estimatedBytes:1500, format:"text", onComplete:completeHandler, onProgress:progressHandler})</code>,
24 * you could use this utility like:<br /><br /><code>
25 *
26 * var vars:DataLoaderVars = new DataLoaderVars();<br />
27 * vars.name = "myData";<br />
28 * vars.estimatedBytes = 1500;<br />
29 * vars.format = "text";<br />
30 * vars.onComplete = completeHandler;<br />
31 * vars.onProgress = progressHandler;<br />
32 * var loader:DataLoader = new DataLoader("getData.php", vars);<br /><br /></code>
33 *
34 * Some of the most common properties can be defined directly in the constructor like this:<br /><br /><code>
35 *
36 * var loader:DataLoader = new DataLoader("getData.php", new DataLoaderVars("myData", 1500, "text", completeHandler, progressHandler) );<br /><br /></code>
37 *
38 * <strong>NOTE:</strong> Using DataLoaderVars is completely optional. If you prefer the shorter synatax with the generic Object, feel
39 * free to use it. The purpose of this class is simply to enable code hinting and to allow for strict data typing. <br /><br />
40 *
41 * <b>Copyright 2010, 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.
42 *
43 * @author Jack Doyle, jack@greensock.com
44 */
45 dynamic public class DataLoaderVars extends LoaderItemVars {
46 /** @private **/
47 private static var _vars:Array = ["format"];
48
49 /** Controls whether the downloaded data is received as text (<code>"text"</code>), raw binary data (<code>"binary"</code>), or URL-encoded variables (<code>"variables"</code>). **/
50 public var format:String;
51
52
53 /**
54 * Constructor
55 *
56 * @param name A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".
57 * @param estimatedBytes Initially, the loader's <code>bytesTotal</code> is set to the <code>estimatedBytes</code> value (or <code>LoaderMax.defaultEstimatedBytes</code> if one isn't defined). Then, when the loader begins loading and it can accurately determine the bytesTotal, it will do so. Setting <code>estimatedBytes</code> is optional, but the more accurate the value, the more accurate your loaders' overall progress will be initially. If the loader is inserted into a LoaderMax instance (for queue management), its <code>auditSize</code> feature can attempt to automatically determine the <code>bytesTotal</code> at runtime (there is a slight performance penalty for this, however - see LoaderMax's documentation for details).
58 * @param format Controls whether the downloaded data is received as text (<code>"text"</code>), raw binary data (<code>"binary"</code>), or URL-encoded variables (<code>"variables"</code>).
59 * @param onComplete A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
60 * @param onProgress A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.
61 * @param onFail A handler function for <code>LoaderEvent.FAIL</code> events which are dispatched whenever the loader fails and its <code>status</code> changes to <code>LoaderStatus.FAILED</code>. Make sure your onFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
62 * @param noCache If <code>true</code>, a "cacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> by <code>url</code> or when you're running locally).
63 * @param alternateURL If you define an <code>alternateURL</code>, the loader will initially try to load from its original <code>url</code> and if it fails, it will automatically (and permanently) change the loader's <code>url</code> to the <code>alternateURL</code> and try again. Think of it as a fallback or backup <code>url</code>. It is perfectly acceptable to use the same <code>alternateURL</code> for multiple loaders (maybe a default image for various ImageLoaders for example).
64 * @param requireWithRoot LoaderMax supports <i>subloading</i>, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this loader as part of its parent SWFLoader's progress, you must set the <code>requireWithRoot</code> property to your swf's <code>root</code>. For example, <code>vars.requireWithRoot = this.root;</code>.
65 */
66 public function DataLoaderVars(name:String="",
67 estimatedBytes:uint=0,
68 format:String="text",
69 onComplete:Function=null,
70 onProgress:Function=null,
71 onFail:Function=null,
72 noCache:Boolean=false,
73 alternateURL:String="",
74 requireWithRoot:DisplayObject=null) {
75 super(name, estimatedBytes, onComplete, onProgress, onFail, noCache, alternateURL, requireWithRoot);
76 _props = _props.concat(_vars);
77 this.format = format;
78 }
79
80 /** Clones the object. **/
81 public function clone():DataLoaderVars {
82 return _cloneProps(new DataLoaderVars()) as DataLoaderVars;
83 }
84
85 }
86 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data {
8 import com.greensock.loading.data.core.DisplayObjectLoaderVars;
9
10 import flash.display.DisplayObject;
11 import flash.display.DisplayObjectContainer;
12 import flash.system.LoaderContext;
13 /**
14 * Can be used instead of a generic object to define the <code>vars</code> parameter of an ImageLoader's constructor. <br /><br />
15 *
16 * There are 2 primary benefits of using a ImageLoaderVars instance to define your ImageLoader variables:
17 * <ol>
18 * <li> In most code editors, code hinting will be activated which helps remind you which special properties are available in ImageLoader</li>
19 * <li> It enables strict data typing for improved debugging (ensuring, for example, that you don't define a Boolean value for <code>onComplete</code> where a Function is expected).</li>
20 * </ol>
21 *
22 * <strong>USAGE:</strong><br /><br />
23 *
24 * Instead of <code>new ImageLoader("photo1.jpg", {name:"photo1", estimatedBytes:11500, container:this, width:200, height:100, onComplete:completeHandler, onProgress:progressHandler})</code>,
25 * you could use this utility like:<br /><br /><code>
26 *
27 * var vars:ImageLoaderVars = new ImageLoaderVars();<br />
28 * vars.name = "photo1";<br />
29 * vars.estimatedBytes = 11500;<br />
30 * vars.container = this;<br />
31 * vars.width = 200;<br />
32 * vars.height = 100;<br />
33 * vars.onComplete = completeHandler;<br />
34 * vars.onProgress = progressHandler;<br />
35 * var loader:ImageLoader = new ImageLoader("photo1.jpg", vars);<br /><br /></code>
36 *
37 * Some of the most common properties can be defined directly in the constructor like this:<br /><br /><code>
38 *
39 * var loader:ImageLoader = new ImageLoader("photo1.jpg", new ImageLoaderVars("photo1", 11500, this, 200, 100, completeHandler, progressHandler) );<br /><br /></code>
40 *
41 * <strong>NOTE:</strong> Using ImageLoaderVars is completely optional. If you prefer the shorter synatax with the generic Object, feel
42 * free to use it. The purpose of this class is simply to enable code hinting and to allow for strict data typing. <br /><br />
43 *
44 * <b>Copyright 2010, 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.
45 *
46 * @author Jack Doyle, jack@greensock.com
47 */
48 dynamic public class ImageLoaderVars extends DisplayObjectLoaderVars {
49 /** @private **/
50 private static var _vars:Array = ["smoothing","context"];
51
52 /** When <code>smoothing</code> is <code>true</code> (the default), smoothing will be enabled for the image which typically leads to much better scaling results (otherwise the image can look crunchy/jagged). If your image is loaded from another domain where the appropriate crossdomain.xml file doesn't grant permission, Flash will not allow smoothing to be enabled (it's a security restriction). **/
53 public var smoothing:Boolean = true;
54 /** To control whether or not a policy file is checked (which is required if you're loading an image from another domain and you want to use it in BitmapData operations), define a <code>LoaderContext</code> object. By default, the policy file <strong>will</strong> be checked when running remotely, so make sure the appropriate crossdomain.xml file is in place. See Adobe's <code>LoaderContext</code> documentation for details and precautions. **/
55 public var context:LoaderContext;
56
57 /**
58 * Constructor
59 *
60 * @param name A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".
61 * @param estimatedBytes Initially, the loader's <code>bytesTotal</code> is set to the <code>estimatedBytes</code> value (or <code>LoaderMax.defaultEstimatedBytes</code> if one isn't defined). Then, when the loader begins loading and it can accurately determine the bytesTotal, it will do so. Setting <code>estimatedBytes</code> is optional, but the more accurate the value, the more accurate your loaders' overall progress will be initially. If the loader is inserted into a LoaderMax instance (for queue management), its <code>auditSize</code> feature can attempt to automatically determine the <code>bytesTotal</code> at runtime (there is a slight performance penalty for this, however - see LoaderMax's documentation for details).
62 * @param container A DisplayObjectContainer into which the <code>ContentDisplay</code> Sprite should be added immediately.
63 * @param width Sets the <code>ContentDisplay</code>'s <code>width</code> property (applied before rotation, scaleX, and scaleY).
64 * @param height Sets the <code>ContentDisplay</code>'s <code>height</code> property (applied before rotation, scaleX, and scaleY).
65 * @param scaleMode When a <code>width</code> and <code>height</code> are defined, the <code>scaleMode</code> controls how the loaded image will be scaled to fit the area. The following values are recognized (you may use the <code>com.greensock.layout.ScaleMode</code> constants if you prefer):<code>"stretch" | "proportionalInside" | "proportionalOutside" | "widthOnly" | "heightOnly" | "none"</code>
66 * @param onComplete A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
67 * @param onProgress A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.
68 * @param onFail A handler function for <code>LoaderEvent.FAIL</code> events which are dispatched whenever the loader fails and its <code>status</code> changes to <code>LoaderStatus.FAILED</code>. Make sure your onFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
69 * @param noCache If <code>true</code>, a "cacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> by <code>url</code> or when you're running locally).
70 * @param alternateURL If you define an <code>alternateURL</code>, the loader will initially try to load from its original <code>url</code> and if it fails, it will automatically (and permanently) change the loader's <code>url</code> to the <code>alternateURL</code> and try again. Think of it as a fallback or backup <code>url</code>. It is perfectly acceptable to use the same <code>alternateURL</code> for multiple loaders (maybe a default image for various ImageLoaders for example).
71 * @param requireWithRoot LoaderMax supports <i>subloading</i>, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this loader as part of its parent SWFLoader's progress, you must set the <code>requireWithRoot</code> property to your swf's <code>root</code>. For example, <code>vars.requireWithRoot = this.root;</code>.
72 */
73 public function ImageLoaderVars(name:String="",
74 estimatedBytes:uint=0,
75 container:DisplayObjectContainer=null,
76 width:Number=NaN,
77 height:Number=NaN,
78 scaleMode:String="stretch",
79 onComplete:Function=null,
80 onProgress:Function=null,
81 onFail:Function=null,
82 noCache:Boolean=false,
83 alternateURL:String="",
84 requireWithRoot:DisplayObject=null) {
85 super(name, estimatedBytes, container, width, height, scaleMode, onComplete, onProgress, onFail, noCache, alternateURL, requireWithRoot);
86 _props = _props.concat(_vars);
87 }
88
89 /** Clones the object. **/
90 public function clone():ImageLoaderVars {
91 return _cloneProps(new ImageLoaderVars()) as ImageLoaderVars;
92 }
93
94 }
95 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data {
8 import com.greensock.loading.core.LoaderCore;
9 import com.greensock.loading.data.core.LoaderCoreVars;
10 import com.greensock.loading.LoaderMax;
11
12 import flash.display.DisplayObject;
13 /**
14 * Can be used instead of a generic object to define the <code>vars</code> parameter of a LoaderMax's constructor. <br /><br />
15 *
16 * There are 2 primary benefits of using a LoaderMaxVars instance to define your LoaderMax variables:
17 * <ol>
18 * <li> In most code editors, code hinting will be activated which helps remind you which special properties are available in LoaderMax</li>
19 * <li> It enables strict data typing for improved debugging (ensuring, for example, that you don't define a Boolean value for <code>onComplete</code> where a Function is expected).</li>
20 * </ol>
21 *
22 * <strong>USAGE:</strong><br /><br />
23 *
24 * Instead of <code>new LoaderMax({name:"mainQueue", onComplete:completeHandler, onProgress:progressHandler})</code>, you could use this utility like:<br /><br /><code>
25 *
26 * var vars:LoaderMaxVars = new LoaderMaxVars();<br />
27 * vars.name = "mainQueue";<br />
28 * vars.onComplete = completeHandler;<br />
29 * vars.onProgress = progressHandler;<br />
30 * var queue:LoaderMax = new LoaderMax(vars);<br /><br /></code>
31 *
32 * Some of the most common properties can be defined directly in the constructor like this:<br /><br /><code>
33 *
34 * var queue:LoaderMax = new LoaderMax( new LoaderMaxVars("mainQueue", completeHandler, progressHandler) );<br /><br /></code>
35 *
36 * <strong>NOTE:</strong> Using LoaderMaxVars is completely optional. If you prefer the shorter synatax with the generic Object, feel
37 * free to use it. The purpose of this class is simply to enable code hinting and to allow for strict data typing. <br /><br />
38 *
39 * <b>Copyright 2010, 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.
40 *
41 * @author Jack Doyle, jack@greensock.com
42 */
43 dynamic public class LoaderMaxVars extends LoaderCoreVars {
44 /** @private **/
45 private static var _vars:Array = ["auditSize",
46 "maxConnections",
47 "skipFailed",
48 "skipPaused",
49 "loaders",
50 "onChildOpen",
51 "onChildProgress",
52 "onChildComplete",
53 "onChildCancel",
54 "onChildFail",
55 "onScriptAccessDenied"];
56
57 /** By default, when the LoaderMax begins to load it quickly loops through its children and if it finds any that don't have an <code>estimatedBytes</code> defined, it will briefly open a URLStream in order to attempt to determine its <code>bytesTotal</code>, immediately closing the URLStream once the value has been determined. This causes a brief delay initially, but greatly improves the accuracy of the <code>progress</code> and <code>bytesTotal</code> values. Set <code>auditSize</code> to <code>false</code> to prevent the LoaderMax from auditing its childrens' size (it is <code>true</code> by default). For maximum performance, it is best to define an <code>estimatedBytes</code> value for as many loaders as possible to avoid the delay caused by audits. When the LoaderMax audits an XMLLoader, it cannot recognize loaders that will be created from the XML data nor can it recognize loaders inside subloaded swf files from a SWFLoader (it would take far too long to load sufficient data for that - audits should be as fast as possible). If you do not set an appropriate <code>estimatedSize</code> for XMLLoaders or SWFLoaders that contain LoaderMax loaders, you'll notice that the parent LoaderMax's <code>progress</code> and <code>bytesTotal</code> change when the nested loaders are recognized (this is normal). To control the default <code>auditSize</code> value, use the static <code>LoaderMax.defaultAuditSize</code> property. **/
58 public var auditSize:Boolean;
59 /** Maximum number of simultaneous connections that should be used while loading the LoaderMax queue. A higher number will generally result in faster overall load times for the group. The default is 2. This value is instance-based, not system-wide, so if you have two LoaderMax instances that both have a <code>maxConnections</code> value of 3 and they are both loading, there could be up to 6 connections at a time total. Sometimes there are limits imposed by the Flash Player itself or the browser or the user's system, but LoaderMax will do its best to honor the <code>maxConnections</code> you define. **/
60 public var maxConnections:uint;
61 /** If <code>skipFailed</code> is <code>true</code> (the default), any failed loaders in the queue will be skipped. Otherwise, the LoaderMax will stop when it hits a failed loader and the LoaderMax's status will become <code>LoaderStatus.FAILED</code>. **/
62 public var skipFailed:Boolean;
63 /** If <code>skipPaused</code> is <code>true</code> (the default), any paused loaders in the queue will be skipped. Otherwise, the LoaderMax will stop when it hits a paused loader and the LoaderMax's status will become <code>LoaderStatus.FAILED</code>. **/
64 public var skipPaused:Boolean;
65 /** An array of loaders (ImageLoaders, SWFLoaders, XMLLoaders, MP3Loaders, other LoaderMax instances, etc.) that should be immediately inserted into the LoaderMax. **/
66 public var loaders:Array;
67
68 /** A handler function for <code>LoaderEvent.CHILD_OPEN</code> events which are dispatched each time one of the loader's children (or any descendant) begins loading. Make sure your onChildOpen function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
69 public var onChildOpen:Function;
70 /** A handler function for <code>LoaderEvent.CHILD_PROGRESS</code> events which are dispatched each time one of the loader's children (or any descendant) dispatches a <code>PROGRESS</code> event. To listen for changes in the LoaderMax's overall progress, use the <code>onProgress</code> special property instead. You can use the LoaderEvent's <code>target.progress</code> to get the child loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>. The LoaderEvent's <code>currentTarget</code> refers to the LoaderMax, so you can check its overall progress with the LoaderEvent's <code>currentTarget.progress</code>. Make sure your onChildProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
71 public var onChildProgress:Function;
72 /** A handler function for <code>LoaderEvent.CHILD_COMPLETE</code> events which are dispatched each time one of the loader's children (or any descendant) finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
73 public var onChildComplete:Function;
74 /** A handler function for <code>LoaderEvent.CHILD_CANCEL</code> events which are dispatched each time loading is aborted on one of the loader's children (or any descendant) due to either an error or because another loader was prioritized in the queue or because <code>cancel()</code> was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
75 public var onChildCancel:Function;
76 /** A handler function for <code>LoaderEvent.CHILD_FAIL</code> events which are dispatched each time one of the loader's children (or any descendant) fails (and its <code>status</code> chances to <code>LoaderStatus.FAILED</code>). Make sure your onChildFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
77 public var onChildFail:Function;
78 /** A handler function for <code>LoaderEvent.SCRIPT_ACCESS_DENIED</code> events which are dispatched when one of the LoaderMax's children (or any descendant) is loaded from another domain and no crossdomain.xml is in place to grant full script access for things like smoothing or BitmapData manipulation. Make sure your function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).**/
79 public var onScriptAccessDenied:Function;
80
81
82 /**
83 * Constructor
84 *
85 */
86 public function LoaderMaxVars(name:String="",
87 onComplete:Function=null,
88 onProgress:Function=null,
89 onFail:Function=null,
90 maxConnections:uint=2,
91 auditSize:Boolean=true,
92 requireWithRoot:DisplayObject=null,
93 skipFailed:Boolean=true,
94 skipPaused:Boolean=true) {
95 super(name, onComplete, onProgress, onFail, requireWithRoot);
96 _props = _props.concat(_vars);
97 this.maxConnections = maxConnections;
98 this.auditSize = (arguments.length >= 6) ? auditSize : LoaderMax.defaultAuditSize;
99 this.skipFailed = skipFailed;
100 this.skipPaused = skipPaused;
101 }
102
103 /** Clones the object. **/
104 public function clone():LoaderMaxVars {
105 return _cloneProps(new LoaderMaxVars()) as LoaderMaxVars;
106 }
107
108 }
109 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.91
3 * DATE: 2010-09-10
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data {
8 import com.greensock.loading.core.LoaderCore;
9 import com.greensock.loading.data.core.LoaderItemVars;
10
11 import flash.display.DisplayObject;
12 import flash.media.SoundLoaderContext;
13
14 /**
15 * Can be used instead of a generic object to define the <code>vars</code> parameter of an MP3Loader's constructor. <br /><br />
16 *
17 * There are 2 primary benefits of using a MP3LoaderVars instance to define your MP3Loader variables:
18 * <ol>
19 * <li> In most code editors, code hinting will be activated which helps remind you which special properties are available in MP3Loader</li>
20 * <li> It enables strict data typing for improved debugging (ensuring, for example, that you don't define a Boolean value for <code>onComplete</code> where a Function is expected).</li>
21 * </ol>
22 *
23 * <strong>USAGE:</strong><br /><br />
24 *
25 * Instead of <code>new MP3Loader("audio.mp3", {name:"audio", estimatedBytes:11500, autoPlay:false, onComplete:completeHandler, onProgress:progressHandler})</code>,
26 * you could use this utility like:<br /><br /><code>
27 *
28 * var vars:MP3LoaderVars = new MP3LoaderVars();<br />
29 * vars.name = "audio";<br />
30 * vars.estimatedBytes = 11500;<br />
31 * vars.autoPlay = false;<br />
32 * vars.onComplete = completeHandler;<br />
33 * vars.onProgress = progressHandler;<br />
34 * var loader:MP3Loader = new MP3Loader("audio.mp3", vars);<br /><br /></code>
35 *
36 * Some of the most common properties can be defined directly in the constructor like this:<br /><br /><code>
37 *
38 * var loader:MP3Loader = new MP3Loader("audio.mp3", new MP3LoaderVars("audio", 11500, false, completeHandler, progressHandler) );<br /><br /></code>
39 *
40 * <strong>NOTE:</strong> Using MP3LoaderVars is completely optional. If you prefer the shorter synatax with the generic Object, feel
41 * free to use it. The purpose of this class is simply to enable code hinting and to allow for strict data typing. <br /><br />
42 *
43 * <b>Copyright 2010, 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.
44 *
45 * @author Jack Doyle, jack@greensock.com
46 */
47 dynamic public class MP3LoaderVars extends LoaderItemVars {
48 /** @private **/
49 private static var _vars:Array = ["autoPlay",
50 "repeat",
51 "volume",
52 "context",
53 "initThreshold"];
54
55 /** By default the MP3 will begin playing immediately when enough of the file has buffered, but to prevent it from autoPlaying, set <code>autoPlay</code> to <code>false</code>. **/
56 public var autoPlay:Boolean = true;
57 /** Number of times that the mp3 should repeat. To repeat indefinitely, use -1. Default is 0. **/
58 public var repeat:int = 0;
59 /** A value between 0 and 1 indicating the volume at which the sound should play when the MP3Loader's controls are used to play the sound, like <code>playSound()</code> or when <code>autoPlay</code> is <code>true</code> (default volume is 1). **/
60 public var volume:Number = 1;
61 /** To control things like the buffer time and whether or not a policy file is checked, define a <code>SoundLoaderContext</code> object. The default context is null. See Adobe's SoundLoaderContext documentation for details. **/
62 public var context:SoundLoaderContext;
63 /** The minimum number of <code>bytesLoaded</code> to wait for before the <code>LoaderEvent.INIT</code> event is dispatched - the higher the number the more accurate the <code>duration</code> estimate will be when the INIT event is dispatched (the default value is 102400 which is 100k). The MP3's duration cannot be determined with 100% accuracy until it has completely loaded, but it is estimated with more and more accuracy as the file loads. **/
64 public var initThreshold:uint = 102400;
65
66 /**
67 * Constructor
68 *
69 * @param name A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".
70 * @param estimatedBytes Initially, the loader's <code>bytesTotal</code> is set to the <code>estimatedBytes</code> value (or <code>LoaderMax.defaultEstimatedBytes</code> if one isn't defined). Then, when the loader begins loading and it can accurately determine the bytesTotal, it will do so. Setting <code>estimatedBytes</code> is optional, but the more accurate the value, the more accurate your loaders' overall progress will be initially. If the loader is inserted into a LoaderMax instance (for queue management), its <code>auditSize</code> feature can attempt to automatically determine the <code>bytesTotal</code> at runtime (there is a slight performance penalty for this, however - see LoaderMax's documentation for details).
71 * @param autoPlay By default, the MP3 will begin playing as soon as it has been adequately buffered, but to prevent it from playing initially, set <code>autoPlay</code> to <code>false</code>.
72 * @param onComplete A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
73 * @param onProgress A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.
74 * @param onFail A handler function for <code>LoaderEvent.FAIL</code> events which are dispatched whenever the loader fails and its <code>status</code> changes to <code>LoaderStatus.FAILED</code>. Make sure your onFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
75 * @param noCache If <code>true</code>, a "cacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> by <code>url</code> or when you're running locally).
76 * @param alternateURL If you define an <code>alternateURL</code>, the loader will initially try to load from its original <code>url</code> and if it fails, it will automatically (and permanently) change the loader's <code>url</code> to the <code>alternateURL</code> and try again. Think of it as a fallback or backup <code>url</code>. It is perfectly acceptable to use the same <code>alternateURL</code> for multiple loaders (maybe a default image for various ImageLoaders for example).
77 * @param requireWithRoot LoaderMax supports <i>subloading</i>, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this loader as part of its parent SWFLoader's progress, you must set the <code>requireWithRoot</code> property to your swf's <code>root</code>. For example, <code>vars.requireWithRoot = this.root;</code>.
78 */
79 public function MP3LoaderVars(name:String="",
80 estimatedBytes:uint=0,
81 autoPlay:Boolean=true,
82 onComplete:Function=null,
83 onProgress:Function=null,
84 onFail:Function=null,
85 noCache:Boolean=false,
86 alternateURL:String="",
87 requireWithRoot:DisplayObject=null) {
88 super(name, estimatedBytes, onComplete, onProgress, onFail, noCache, alternateURL, requireWithRoot);
89 _props = _props.concat(_vars);
90 this.autoPlay = autoPlay;
91 }
92
93 /** Clones the object. **/
94 public function clone():MP3LoaderVars {
95 return _cloneProps(new MP3LoaderVars()) as MP3LoaderVars;
96 }
97
98 }
99 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data {
8 import com.greensock.loading.core.LoaderCore;
9 import com.greensock.loading.data.core.LoaderItemVars;
10
11 import flash.display.DisplayObject;
12 /**
13 * Can be used instead of a generic object to define the <code>vars</code> parameter of an XMLLoader's constructor. <br /><br />
14 *
15 * There are 2 primary benefits of using a XMLLoaderVars instance to define your XMLLoader variables:
16 * <ol>
17 * <li> In most code editors, code hinting will be activated which helps remind you which special properties are available in XMLLoader</li>
18 * <li> It enables strict data typing for improved debugging (ensuring, for example, that you don't define a Boolean value for <code>onComplete</code> where a Function is expected).</li>
19 * </ol>
20 *
21 * <strong>USAGE:</strong><br /><br />
22 *
23 * Instead of <code>new XMLLoader("getData.php", {name:"myData", estimatedBytes:1500, onComplete:completeHandler, onProgress:progressHandler})</code>,
24 * you could use this utility like:<br /><br /><code>
25 *
26 * var vars:XMLLoaderVars = new XMLLoaderVars();<br />
27 * vars.name = "myData";<br />
28 * vars.estimatedBytes = 1500;<br />
29 * vars.onComplete = completeHandler;<br />
30 * vars.onProgress = progressHandler;<br />
31 * var loader:XMLLoader = new XMLLoader("getData.php", vars);<br /><br /></code>
32 *
33 * Some of the most common properties can be defined directly in the constructor like this:<br /><br /><code>
34 *
35 * var loader:XMLLoader = new XMLLoader("getData.php", new XMLLoaderVars("myData", 1500, completeHandler, progressHandler) );<br /><br /></code>
36 *
37 * <strong>NOTE:</strong> Using XMLLoaderVars is completely optional. If you prefer the shorter synatax with the generic Object, feel
38 * free to use it. The purpose of this class is simply to enable code hinting and to allow for strict data typing. <br /><br />
39 *
40 * <b>Copyright 2010, 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.
41 *
42 * @author Jack Doyle, jack@greensock.com
43 */
44 dynamic public class XMLLoaderVars extends LoaderItemVars {
45 /** @private **/
46 private static var _vars:Array = ["integrateProgress",
47 "onChildOpen",
48 "onChildProgress",
49 "onChildComplete",
50 "onChildCancel",
51 "onChildFail"];
52
53 /** By default, the XMLLoader will automatically look for LoaderMax-related nodes like <code>&lt;LoaderMax&gt;, &lt;ImageLoader&gt;, &lt;SWFLoader&gt;, &lt;XMLLoader&gt;, &lt;MP3Loader&gt;, &lt;DataLoader&gt;</code>, and <code>&lt;CSSLoader&gt;</code> inside the XML when it inits. If it finds any that have a <code>load="true"</code> attribute, it will begin loading them and integrate their progress into the XMLLoader's overall progress. Its <code>COMPLETE</code> event won't fire until all of these loaders have completed as well. If you prefer NOT to integrate the dynamically-created loader instances into the XMLLoader's overall <code>progress</code>, set <code>integrateProgress</code> to <code>false</code>. **/
54 public var integrateProgress:Boolean=true;
55 /** A handler function for <code>LoaderEvent.CHILD_OPEN</code> events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML begins loading. Make sure your onChildOpen function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
56 public var onChildOpen:Function;
57 /** A handler function for <code>LoaderEvent.CHILD_PROGRESS</code> events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML dispatches a <code>PROGRESS</code> event. To listen for changes in the XMLLoader's overall progress, use the <code>onProgress</code> special property instead. You can use the LoaderEvent's <code>target.progress</code> to get the child loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>. The LoaderEvent's <code>currentTarget</code> refers to the XMLLoader, so you can check its overall progress with the LoaderEvent's <code>currentTarget.progress</code>. Make sure your onChildProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
58 public var onChildProgress:Function;
59 /** A handler function for <code>LoaderEvent.CHILD_COMPLETE</code> events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
60 public var onChildComplete:Function;
61 /** A handler function for <code>LoaderEvent.CHILD_CANCEL</code> events which are dispatched each time loading is aborted on any nested LoaderMax-related loaders that were defined in the XML due to either an error or because another loader was prioritized in the queue or because <code>cancel()</code> was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
62 public var onChildCancel:Function;
63 /** A handler function for <code>LoaderEvent.CHILD_FAIL</code> events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML fails (and its <code>status</code> chances to <code>LoaderStatus.FAILED</code>). Make sure your onChildFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
64 public var onChildFail:Function;
65
66 /**
67 * Constructor
68 *
69 * @param name A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".
70 * @param estimatedBytes Initially, the loader's <code>bytesTotal</code> is set to the <code>estimatedBytes</code> value (or <code>LoaderMax.defaultEstimatedBytes</code> if one isn't defined). Then, when the loader begins loading and it can accurately determine the bytesTotal, it will do so. Setting <code>estimatedBytes</code> is optional, but the more accurate the value, the more accurate your loaders' overall progress will be initially. If the loader is inserted into a LoaderMax instance (for queue management), its <code>auditSize</code> feature can attempt to automatically determine the <code>bytesTotal</code> at runtime (there is a slight performance penalty for this, however - see LoaderMax's documentation for details).
71 * @param onComplete A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
72 * @param onProgress A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.
73 * @param onFail A handler function for <code>LoaderEvent.FAIL</code> events which are dispatched whenever the loader fails and its <code>status</code> changes to <code>LoaderStatus.FAILED</code>. Make sure your onFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).
74 * @param noCache If <code>true</code>, a "cacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> by <code>url</code> or when you're running locally).
75 * @param alternateURL If you define an <code>alternateURL</code>, the loader will initially try to load from its original <code>url</code> and if it fails, it will automatically (and permanently) change the loader's <code>url</code> to the <code>alternateURL</code> and try again. Think of it as a fallback or backup <code>url</code>. It is perfectly acceptable to use the same <code>alternateURL</code> for multiple loaders (maybe a default image for various ImageLoaders for example).
76 * @param requireWithRoot LoaderMax supports <i>subloading</i>, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this loader as part of its parent SWFLoader's progress, you must set the <code>requireWithRoot</code> property to your swf's <code>root</code>. For example, <code>vars.requireWithRoot = this.root;</code>.
77 */
78 public function XMLLoaderVars(name:String="",
79 estimatedBytes:uint=0,
80 onComplete:Function=null,
81 onProgress:Function=null,
82 onFail:Function=null,
83 noCache:Boolean=false,
84 alternateURL:String="",
85 requireWithRoot:DisplayObject=null) {
86 super(name, estimatedBytes, onComplete, onProgress, onFail, noCache, alternateURL, requireWithRoot);
87 _props = _props.concat(_vars);
88 }
89
90 /** Clones the object. **/
91 public function clone():XMLLoaderVars {
92 return _cloneProps(new XMLLoaderVars()) as XMLLoaderVars;
93 }
94
95 }
96 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data.core {
8 import com.greensock.loading.core.LoaderCore;
9
10 import flash.display.DisplayObject;
11 /**
12 * Facilitates code hinting and data type enforcement for the <code>vars</code> object that's passed into the
13 * constructor of various loaders in the LoaderMax system. There is no reason to use this class directly - see
14 * docs for the vars classes that extend LoaderCoreVars like XMLLoaderVars, SWFLoaderVars, LoaderMaxVars, etc.<br /><br />
15 *
16 * <b>Copyright 2010, 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.
17 *
18 * @author Jack Doyle, jack@greensock.com
19 */
20 dynamic public class LoaderCoreVars {
21 /** @private **/
22 private static var _vars:Array = ["name",
23 "onComplete",
24 "onProgress",
25 "onFail",
26 "requireWithRoot",
27 "autoDispose",
28 "onOpen",
29 "onCancel",
30 "onError",
31 "onIOError",
32 "onHTTPStatus"];
33
34 /** A name that is used to identify the loader instance. This name can be fed to the <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21". **/
35 public var name:String;
36 /** A handler function for <code>LoaderEvent.COMPLETE</code> events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
37 public var onComplete:Function;
38 /** A handler function for <code>LoaderEvent.PROGRESS</code> events which are dispatched whenever the <code>bytesLoaded</code> changes. Make sure your onProgress function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can use the LoaderEvent's <code>target.progress</code> to get the loader's progress value or use its <code>target.bytesLoaded</code> and <code>target.bytesTotal</code>.**/
39 public var onProgress:Function;
40 /** A handler function for <code>LoaderEvent.FAIL</code> events which are dispatched whenever the loader fails and its <code>status</code> changes to <code>LoaderStatus.FAILED</code>. Make sure your onFail function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
41 public var onFail:Function;
42 /** LoaderMax supports <i>subloading</i>, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this loader as part of its parent SWFLoader's progress, you must set the <code>requireWithRoot</code> property to your swf's <code>root</code>. For example, <code>vars.requireWithRoot = this.root;</code>. **/
43 public var requireWithRoot:DisplayObject;
44 /** When <code>autoDispose</code> is <code>true</code>, the loader will be disposed immediately after it completes (it calls the <code>dispose()</code> method internally after dispatching its <code>COMPLETE</code> event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> - it is essentially destroyed but its content is not unloaded (you must call <code>unload()</code> or <code>dispose(true)</code> to unload its content). The default <code>autoDispose</code> value is <code>false</code>.**/
45 public var autoDispose:Boolean;
46 /** A handler function for <code>LoaderEvent.OPEN</code> events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).**/
47 public var onOpen:Function;
48 /** A handler function for <code>LoaderEvent.CANCEL</code> events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or <code>cancel()</code> was manually called. Make sure your onCancel function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
49 public var onCancel:Function;
50 /** A handler function for <code>LoaderEvent.ERROR</code> events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the <code>onFail</code> special property. Make sure your onError function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). **/
51 public var onError:Function;
52 /** A handler function for <code>LoaderEvent.IO_ERROR</code> events which will also call the onError handler, so you can use that as more of a catch-all whereas <code>onIOError</code> is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>).</li> **/
53 public var onIOError:Function;
54 /** A handler function for <code>LoaderEvent.HTTP_STATUS</code> events. Make sure your onHTTPStatus function accepts a single parameter of type <code>LoaderEvent</code> (<code>com.greensock.events.LoaderEvent</code>). You can determine the httpStatus code using the LoaderEvent's <code>target.httpStatus</code> (LoaderItems keep track of their <code>httpStatus</code> when possible, although certain environments prevent Flash from getting httpStatus information).**/
55 public var onHTTPStatus:Function;
56
57 /** @private **/
58 protected var _props:Array;
59
60
61 /**
62 * Constructor
63 * @private
64 */
65 public function LoaderCoreVars(name:String="",
66 onComplete:Function=null,
67 onProgress:Function=null,
68 onFail:Function=null,
69 requireWithRoot:DisplayObject=null) {
70 _props = _vars.slice();
71 this.name = name;
72 this.onComplete = onComplete;
73 this.onProgress = onProgress;
74 this.onFail = onFail;
75 this.requireWithRoot = requireWithRoot;
76 }
77
78 /** @private **/
79 protected function _cloneProps(vars:LoaderCoreVars):LoaderCoreVars {
80 for each (var p:String in _props) {
81 vars[p] = this[p];
82 }
83 for (p in this) { //now do the dynamic props.
84 vars[p] = this[p];
85 }
86 return vars;
87 }
88
89 }
90 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-08-09
4 * AS3
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com/LoaderMax/
6 **/
7 package com.greensock.loading.data.core {
8 import com.greensock.loading.data.core.LoaderCoreVars;
9
10 import flash.display.DisplayObject;
11 /**
12 * Facilitates code hinting and data type enforcement for the <code>vars</code> object that's passed into the
13 * constructor of various LoaderItems in the LoaderMax system. There is no reason to use this class directly - see
14 * docs for the vars classes that extend LoaderItemVars like XMLLoaderVars, SWFLoaderVars, etc.<br /><br />
15 *
16 * <b>Copyright 2010, 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.
17 *
18 * @author Jack Doyle, jack@greensock.com
19 */
20 dynamic public class LoaderItemVars extends LoaderCoreVars {
21 /** @private **/
22 private static var _vars:Array = ["estimatedBytes",
23 "noCache",
24 "alternateURL"];
25
26 /** If you define an <code>alternateURL</code>, the loader will initially try to load from its original <code>url</code> and if it fails, it will automatically (and permanently) change the loader's <code>url</code> to the <code>alternateURL</code> and try again. Think of it as a fallback or backup <code>url</code>. It is perfectly acceptable to use the same <code>alternateURL</code> for multiple loaders (maybe a default image for various ImageLoaders for example). **/
27 public var alternateURL:String;
28 /** If <code>true</code>, a "cacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you <code>LoaderMax.getLoader()</code> or <code>LoaderMax.getContent()</code> by <code>url</code> or when you're running locally). **/
29 public var noCache:Boolean;
30 /** Initially, the loader's <code>bytesTotal</code> is set to the <code>estimatedBytes</code> value (or <code>LoaderMax.defaultEstimatedBytes</code> if one isn't defined). Then, when the loader begins loading and it can accurately determine the bytesTotal, it will do so. Setting <code>estimatedBytes</code> is optional, but the more accurate the value, the more accurate your loaders' overall progress will be initially. If the loader is inserted into a LoaderMax instance (for queue management), its <code>auditSize</code> feature can attempt to automatically determine the <code>bytesTotal</code> at runtime (there is a slight performance penalty for this, however - see LoaderMax's documentation for details). **/
31 public var estimatedBytes:uint;
32
33 /**
34 * Constructor
35 * @private
36 */
37 public function LoaderItemVars(name:String="",
38 estimatedBytes:uint=0,
39 onComplete:Function=null,
40 onProgress:Function=null,
41 onFail:Function=null,
42 noCache:Boolean=false,
43 alternateURL:String="",
44 requireWithRoot:DisplayObject=null) {
45 super(name, onComplete, onProgress, onFail, requireWithRoot);
46 _props = _props.concat(_vars);
47 this.estimatedBytes = estimatedBytes;
48 this.noCache = noCache;
49 this.alternateURL = alternateURL;
50 }
51
52 }
53 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.1 (beta)
3 * DATE: 1/19/2010
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com
6 **/
7 package com.greensock.motionPaths {
8
9 /**
10 * Constants for defining the direction in which to travel on a MotionPath (like <code>CLOCKWISE, COUNTER_CLOCKWISE, SHORTEST,</code> etc.). <br /><br />
11 *
12 * <b>Copyright 2010, 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.
13 *
14 * @author Jack Doyle, jack@greensock.com
15 */
16 public class Direction {
17 public static const CLOCKWISE:String="clockwise";
18 public static const COUNTER_CLOCKWISE:String="counterClockwise";
19 public static const SHORTEST:String="shortest";
20 }
21 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.2 (beta)
3 * DATE: 2010-04-21
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com
6 **/
7 package com.greensock.motionPaths {
8 /**
9 * A PathFollower is used to associate a particular target object (like a MovieClip, Point, Sprite, etc.)
10 * with a MotionPath and it offers a tweenable <code>progress</code> property that manages positioning
11 * the target on the path accordingly. The <code>progress</code> property is a value between
12 * 0 and 1 where 0 is at the beginning of the path, 0.5 is in the middle, and 1 is at the end.
13 * When the follower's <code>autoRotate</code> property is <code>true</code>, the target will be
14 * rotated in relation to the path that it is following. <br /><br />
15 *
16 * @example Example AS3 code:<listing version="3.0">
17 import com.greensock.~~;
18 import com.greensock.motionPaths.~~;
19
20 //create a circle motion path at coordinates x:150, y:150 with a radius of 100
21 var circle:Circle2D = new Circle2D(150, 150, 100);
22
23 //make the MovieClip "mc" follow the circle and start at a position of 90 degrees (this returns a PathFollower instance)
24 var follower:PathFollower = circle.addFollower(mc, circle.angleToProgress(90), true);
25
26 //tween the follower clockwise along the path to 315 degrees
27 TweenLite.to(follower, 2, {progress:circle.followerTween(follower, 315, Direction.CLOCKWISE)});
28
29 //tween the follower counter-clockwise to 200 degrees and add an extra revolution
30 TweenLite.to(follower, 2, {progress:circle.followerTween(follower, 200, Direction.COUNTER_CLOCKWISE, 1)});
31 </listing>
32 *
33 * <b>NOTES</b><br />
34 * <ul>
35 * <li>All followers are automatically updated when you alter the MotionPath that they're following.</li>
36 * <li>To tween all followers along the path at once, simply tween the MotionPath's <code>progress</code>
37 * property which will provide better performance than tweening each follower independently.</li>
38 * </ul>
39 *
40 * <b>Copyright 2010, 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.
41 *
42 * @author Jack Doyle, jack@greensock.com
43 */
44 public class PathFollower {
45 /** The target object associated with the PathFollower (like a Sprite, MovieClip, Point, etc.). The object must have x and y properties. **/
46 public var target:Object;
47
48 /** @private **/
49 public var cachedProgress:Number;
50 /** @private **/
51 public var cachedNext:PathFollower;
52 /** @private **/
53 public var cachedPrev:PathFollower;
54
55 /** The MotionPath instance that this PathFollower should follow **/
56 public var path:MotionPath;
57 /** When <code>autoRotate</code> is <code>true</code>, the follower will automatically be rotated so that it is oriented to the angle of the path that it is following. To offset this value (like to always add 90 degrees for example), use the <code>rotationOffset</code> property. **/
58 public var autoRotate:Boolean;
59 /** When <code>autoRotate</code> is <code>true</code>, this value will always be added to the resulting <code>rotation</code> of the target. **/
60 public var rotationOffset:Number;
61
62 /**
63 * Constructor
64 *
65 * @param target The target object associated with the PathFollower (like a Sprite, MovieClip, Point, etc.). The object must have x and y properties.
66 * @param autoRotate When <code>autoRotate</code> is <code>true</code>, the follower will automatically be rotated so that it is oriented to the angle of the path that it is following. To offset this value (like to always add 90 degrees for example), use the <code>rotationOffset</code> property.
67 * @param rotationOffset When <code>autoRotate</code> is <code>true</code>, this value will always be added to the resulting <code>rotation</code> of the target.
68 */
69 public function PathFollower(target:Object, autoRotate:Boolean=false, rotationOffset:Number=0) {
70 this.target = target;
71 this.autoRotate = autoRotate;
72 this.rotationOffset = rotationOffset;
73 this.cachedProgress = 0;
74 }
75
76 /**
77 * A value (typically between 0 and 1) that can be used to move all followers along the path. You can tween to
78 * values that are greater than 1 or less than 0 but the values are simply wrapped. So, for example, setting
79 * <code>progress</code> to 1.2 is the same as setting it to 0.2 and -0.2 is the same as 0.8. If your goal is to
80 * tween the PathFollower around a Circle2D twice completely, you could just add 2 to the <code>progress</code>
81 * value or use a relative value in the tween, like: <br /><br /><code>
82 *
83 * TweenLite.to(myFollower, 5, {progress:"2"}); //or myFollower.progress + 2
84 *
85 * </code>
86 **/
87 public function get progress():Number {
88 return this.cachedProgress;
89 }
90 public function set progress(value:Number):void {
91 if (value > 1) {
92 value -= int(value);
93 } else if (value < 0) {
94 value -= int(value) - 1;
95 }
96 this.cachedProgress = value;
97 if (this.path) {
98 this.path.renderObjectAt(this.target, value, this.autoRotate, this.rotationOffset);
99 }
100 }
101
102 }
103 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.2 (beta)
3 * DATE: 2010-04-21
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com
6 **/
7 package com.greensock.motionPaths {
8 import flash.display.Graphics;
9 import flash.geom.Matrix;
10 /**
11 * A RectanglePath2D defines a rectangular path on which a PathFollower can be placed, making it simple to tween objects
12 * along a rectangle's perimeter. A PathFollower's position along the path is described using its <code>progress</code> property,
13 * a value between 0 and 1 where 0 is at the beginning of the path (top left corner), and as the value increases, it
14 * moves clockwise along the path so that 0.5 would be at the lower right corner, and 1 is all the way back at the
15 * upper left corner of the path. So to tween a PathFollower along the path, you can simply tween its
16 * <code>progress</code> property. To tween ALL of the followers on the path at once, you can tween the
17 * RectanglePath2D's <code>progress</code> property. PathFollowers automatically wrap so that if the <code>progress</code>
18 * value exceeds 1 it continues at the beginning of the path.<br /><br />
19 *
20 * Since RectanglePath2D extends the Shape class, you can add an instance to the display list to see a line representation
21 * of the path drawn which can be helpful especially during the production phase. Use <code>lineStyle()</code>
22 * to adjust the color, thickness, and other attributes of the line that is drawn (or set the RectanglePath2D's
23 * <code>visible</code> property to false or don't add it to the display list if you don't want to see the line
24 * at all). You can also adjust all of its properties like <code>scaleX, scaleY, rotation, width, height, x,</code>
25 * and <code>y</code>. That means you can tween those values as well to achieve very dynamic, complex effects
26 * with ease.<br /><br />
27 *
28 * @example Example AS3 code:<listing version="3.0">
29 import com.greensock.~~;
30 import com.greensock.motionPaths.~~;
31
32 //create a rectangular motion path at coordinates x:25, y:25 with a width of 150 and a height of 100
33 var rect:RectanglePath2D = new RectanglePath2D(25, 25, 150, 100, false);
34
35 //position the MovieClip "mc" at the beginning of the path (upper left corner), and reference the resulting PathFollower instance with a "follower" variable.
36 var follower:PathFollower = rect.addFollower(mc, 0);
37
38 //tween the follower clockwise along the path all the way to the end, one full revolution
39 TweenLite.to(follower, 2, {progress:1});
40
41 //tween the follower counter-clockwise by using a negative progress value
42 TweenLite.to(follower, 2, {progress:-1});
43 </listing>
44 *
45 * <b>NOTES</b><br />
46 * <ul>
47 * <li>All followers' positions are automatically updated when you alter the MotionPath that they're following.</li>
48 * <li>To tween all followers along the path at once, simply tween the MotionPath's <code>progress</code>
49 * property which will provide better performance than tweening each follower independently.</li>
50 * </ul>
51 *
52 * <b>Copyright 2010, 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.
53 *
54 * @author Jack Doyle, jack@greensock.com
55 */
56 public class RectanglePath2D extends MotionPath {
57 /** @private **/
58 protected var _rawWidth:Number;
59 /** @private **/
60 protected var _rawHeight:Number;
61 /** @private **/
62 protected var _centerOrigin:Boolean;
63
64 /**
65 * Constructor
66 *
67 * @param x The x coordinate of the origin of the rectangle (typically its top left corner unless <code>centerOrigin</code> is <code>true</code>)
68 * @param y The y coordinate of the origin of the rectangle (typically its top left corner unless <code>centerOrigin</code> is <code>true</code>)
69 * @param rawWidth The width of the rectangle in its unrotated and unscaled state
70 * @param rawHeight The height of the rectangle in its unrotated and unscaled state
71 * @param centerOrigin To position the origin (registration point around which transformations occur) at the center of the rectangle instead of its upper left corner, set <code>centerOrigin</code> to <code>true</code> (it is false by default).
72 */
73 public function RectanglePath2D(x:Number, y:Number, rawWidth:Number, rawHeight:Number, centerOrigin:Boolean=false) {
74 super();
75 _rawWidth = rawWidth;
76 _rawHeight = rawHeight;
77 _centerOrigin = centerOrigin;
78 super.x = x;
79 super.y = y;
80 }
81
82 /** @private **/
83 override protected function renderAll():void {
84 var xOffset:Number = _centerOrigin ? _rawWidth / -2 : 0;
85 var yOffset:Number = _centerOrigin ? _rawHeight / -2 : 0;
86
87 var length:Number, px:Number, py:Number, xFactor:Number, yFactor:Number;
88 var m:Matrix = this.transform.matrix;
89 var a:Number = m.a, b:Number = m.b, c:Number = m.c, d:Number = m.d, tx:Number = m.tx, ty:Number = m.ty;
90 var f:PathFollower = _rootFollower;
91 while (f) {
92 px = xOffset;
93 py = yOffset;
94 if (f.cachedProgress < 0.5) {
95 length = f.cachedProgress * (_rawWidth + _rawHeight) * 2;
96 if (length > _rawWidth) { //top
97 px += _rawWidth;
98 py += length - _rawWidth;
99 xFactor = 0;
100 yFactor = _rawHeight;
101 } else { //right
102 px += length;
103 xFactor = _rawWidth;
104 yFactor = 0;
105 }
106 } else {
107 length = (f.cachedProgress - 0.5) / 0.5 * (_rawWidth + _rawHeight);
108 if (length <= _rawWidth) { //bottom
109 px += _rawWidth - length;
110 py += _rawHeight;
111 xFactor = -_rawWidth;
112 yFactor = 0;
113 } else { //left
114 py += _rawHeight - (length - _rawWidth);
115 xFactor = 0;
116 yFactor = -_rawHeight;
117 }
118 }
119
120 f.target.x = px * a + py * c + tx;
121 f.target.y = px * b + py * d + ty;
122
123 if (f.autoRotate) {
124 f.target.rotation = Math.atan2(xFactor * b + yFactor * d, xFactor * a + yFactor * c) * _RAD2DEG + f.rotationOffset;
125 }
126
127 f = f.cachedNext;
128 }
129 if (_redrawLine && this.visible && this.parent) {
130 var g:Graphics = this.graphics;
131 g.clear();
132 g.lineStyle(_thickness, _color, _lineAlpha, _pixelHinting, _scaleMode, _caps, _joints, _miterLimit);
133 g.drawRect(xOffset, yOffset, _rawWidth, _rawHeight);
134 _redrawLine = false;
135 }
136 }
137
138 /** @inheritDoc **/
139 override public function renderObjectAt(target:Object, progress:Number, autoRotate:Boolean=false, rotationOffset:Number=0):void {
140 if (progress > 1) {
141 progress -= int(progress);
142 } else if (progress < 0) {
143 progress -= int(progress) - 1;
144 }
145
146 var px:Number = _centerOrigin ? _rawWidth / -2 : 0;
147 var py:Number = _centerOrigin ? _rawHeight / -2 : 0;
148 var length:Number, xFactor:Number, yFactor:Number;
149 if (progress < 0.5) {
150 length = progress * (_rawWidth + _rawHeight) * 2;
151 if (length > _rawWidth) {
152 px += _rawWidth;
153 py += length - _rawWidth;
154 xFactor = 0;
155 yFactor = _rawHeight;
156 } else {
157 px += length;
158 xFactor = _rawWidth;
159 yFactor = 0;
160 }
161 } else {
162 length = (progress - 0.5) / 0.5 * (_rawWidth + _rawHeight);
163 if (length <= _rawWidth) {
164 px += _rawWidth - length;
165 py += _rawHeight;
166 xFactor = -_rawWidth;
167 yFactor = 0;
168 } else {
169 py += _rawHeight - (length - _rawWidth);
170 xFactor = 0;
171 yFactor = -_rawHeight;
172 }
173 }
174 var m:Matrix = this.transform.matrix;
175 target.x = px * m.a + py * m.c + m.tx;
176 target.y = px * m.b + py * m.d + m.ty;
177
178 if (autoRotate) {
179 target.rotation = Math.atan2(xFactor * m.b + yFactor * m.d, xFactor * m.a + yFactor * m.c) * _RAD2DEG + rotationOffset;
180 }
181 }
182
183
184 //---- GETTERS / SETTERS ----------------------------------------------------------------------
185
186 /** width of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation) **/
187 public function get rawWidth():Number {
188 return _rawWidth;
189 }
190 public function set rawWidth(value:Number):void {
191 _rawWidth = value;
192 _redrawLine = true;
193 renderAll();
194 }
195
196 /** height of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation) **/
197 public function get rawHeight():Number {
198 return _rawHeight;
199 }
200 public function set rawHeight(value:Number):void {
201 _rawHeight = value;
202 _redrawLine = true;
203 renderAll();
204 }
205
206 /** height of the rectangle in its unrotated, unscaled state (does not factor in any transformations like scaleX/scaleY/rotation) **/
207 public function get centerOrigin():Boolean {
208 return _centerOrigin;
209 }
210 public function set centerOrigin(value:Boolean):void {
211 _centerOrigin;
212 _redrawLine = true;
213 renderAll();
214 }
215
216 }
217 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.3
3 * DATE: 10/17/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
10 import flash.display.*;
11 /**
12 * Tweening "autoAlpha" is exactly the same as tweening an object's "alpha" except that it ensures
13 * that the object's "visible" property is true until autoAlpha reaches zero at which point it will
14 * toggle the "visible" property to false. That not only improves rendering performance in the Flash Player,
15 * but also hides DisplayObjects so that they don't interact with the mouse. <br /><br />
16 *
17 * <b>USAGE:</b><br /><br />
18 * <code>
19 * import com.greensock.TweenLite; <br />
20 * import com.greensock.plugins.TweenPlugin; <br />
21 * import com.greensock.plugins.AutoAlphaPlugin; <br />
22 * TweenPlugin.activate([AutoAlphaPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
23 *
24 * TweenLite.to(mc, 2, {autoAlpha:0}); <br /><br />
25 * </code>
26 *
27 * <b>Copyright 2010, 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 AutoAlphaPlugin 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 protected var _target:Object;
37 /** @private **/
38 protected var _ignoreVisible:Boolean;
39
40 /** @private **/
41 public function AutoAlphaPlugin() {
42 super();
43 this.propName = "autoAlpha";
44 this.overwriteProps = ["alpha","visible"];
45 }
46
47 /** @private **/
48 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
49 _target = target;
50 addTween(target, "alpha", target.alpha, value, "alpha");
51 return true;
52 }
53
54 /** @private **/
55 override public function killProps(lookup:Object):void {
56 super.killProps(lookup);
57 _ignoreVisible = Boolean("visible" in lookup);
58 }
59
60 /** @private **/
61 override public function set changeFactor(n:Number):void {
62 updateTweens(n);
63 if (!_ignoreVisible) {
64 _target.visible = Boolean(_target.alpha != 0);
65 }
66 }
67
68 }
69 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.0
3 * DATE: 8/18/2009
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com
6 **/
7 package com.greensock.plugins {
8 import flash.filters.*;
9 import flash.display.*;
10 import com.greensock.*;
11 /**
12 * Tweens a BevelFilter. The following properties are available (you only need to define the ones you want to tween): <br />
13 * <code>
14 * <ul>
15 * <li> distance : Number [0]</li>
16 * <li> angle : Number [0]</li>
17 * <li> highlightColor : uint [0xFFFFFF]</li>
18 * <li> highlightAlpha : Number [0.5]</li>
19 * <li> shadowColor : uint [0x000000]</li>
20 * <li> shadowAlpha :Number [0.5]</li>
21 * <li> blurX : Number [2]</li>
22 * <li> blurY : Number [2]</li>
23 * <li> strength : Number [0]</li>
24 * <li> quality : uint [2]</li>
25 * <li> index : uint</li>
26 * <li> addFilter : Boolean [false]</li>
27 * <li> remove : Boolean [false]</li>
28 * </ul>
29 * </code>
30 *
31 *
32 * <b>USAGE:</b><br /><br />
33 * <code>
34 * import com.greensock.TweenLite; <br />
35 * import com.greensock.plugins.TweenPlugin; <br />
36 * import com.greensock.plugins.BevelFilterPlugin; <br />
37 * TweenPlugin.activate([BevelFilterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
38 *
39 * TweenLite.to(mc, 1, {bevelFilter:{blurX:10, blurY:10, distance:6, angle:45, strength:1}});<br /><br />
40 * </code>
41 *
42 * <b>Copyright 2010, 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.
43 *
44 * @author Jack Doyle, jack@greensock.com
45 */
46 public class BevelFilterPlugin extends FilterPlugin {
47 /** @private **/
48 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
49 /** @private **/
50 private static var _propNames:Array = ["distance","angle","highlightColor","highlightAlpha","shadowColor","shadowAlpha","blurX","blurY","strength","quality"];
51
52 /** @private **/
53 public function BevelFilterPlugin() {
54 super();
55 this.propName = "bevelFilter";
56 this.overwriteProps = ["bevelFilter"];
57 }
58
59 /** @private **/
60 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
61 _target = target;
62 _type = BevelFilter;
63 initFilter(value, new BevelFilter(0, 0, 0xFFFFFF, 0.5, 0x000000, 0.5, 2, 2, 0, value.quality || 2), _propNames);
64 return true;
65 }
66
67 }
68 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.21
3 * DATE: 2010-06-23
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 /**
10 * Bezier tweening allows you to tween in a non-linear way. For example, you may want to tween
11 * a MovieClip's position from the origin (0,0) 500 pixels to the right (500,0) but curve downwards
12 * through the middle of the tween. Simply pass as many objects in the bezier Array as you'd like,
13 * one for each "control point" (see documentation on Flash's curveTo() drawing method for more
14 * about how control points work).<br /><br />
15 *
16 * Keep in mind that you can bezier tween ANY properties, not just x/y. <br /><br />
17 *
18 * Also, if you'd like to rotate the target in the direction of the bezier path,
19 * use the <code>orientToBezier</code> special property. In order to alter a rotation property accurately,
20 * TweenLite/Max needs 5 pieces of information: <br />
21 * <ol>
22 * <li> Position property 1 (typically <code>"x"</code>)</li>
23 * <li> Position property 2 (typically <code>"y"</code>)</li>
24 * <li> Rotational property (typically <code>"rotation"</code>)</li>
25 * <li> Number of degrees to add (optional - makes it easy to orient your MovieClip properly)</li>
26 * <li> Tolerance (default is 0.01, but increase this if the rotation seems to jitter during the tween)</li>
27 * </ol><br />
28 *
29 * The <code>orientToBezier</code> property should be an Array containing one Array for each set of these values.
30 * For maximum flexibility, you can pass in any number of arrays inside the container array, one
31 * for each rotational property. This can be convenient when working in 3D because you can rotate
32 * on multiple axis. If you're doing a standard 2D x/y tween on a bezier, you can simply pass
33 * in a Boolean value of true and TweenLite/Max will use a typical setup, <code>[["x", "y", "rotation", 0, 0.01]]</code>.
34 * Hint: Don't forget the container Array (notice the double outer brackets)<br /><br />
35 *
36 * <b>USAGE:</b><br /><br />
37 * <code>
38 * import com.greensock.TweenLite; <br />
39 * import com.greensock.plugins.TweenPlugin; <br />
40 * import com.greensock.plugins.BezierPlugin; <br />
41 * TweenPlugin.activate([BezierPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
42 *
43 * TweenLite.to(mc, 3, {bezier:[{x:250, y:50}, {x:500, y:0}]}); //makes my_mc travel through 250,50 and end up at 500,0. <br /><br />
44 * </code>
45 *
46 * <b>Copyright 2010, 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.
47 *
48 * @author Jack Doyle, jack@greensock.com
49 */
50 public class BezierPlugin extends TweenPlugin {
51 /** @private **/
52 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
53
54 /** @private **/
55 protected static const _RAD2DEG:Number = 180 / Math.PI; //precalculate for speed
56
57 /** @private **/
58 protected var _target:Object;
59 /** @private **/
60 protected var _orientData:Array;
61 /** @private **/
62 protected var _orient:Boolean;
63 /** @private used for orientToBezier projections **/
64 protected var _future:Object = {};
65 /** @private **/
66 protected var _beziers:Object;
67
68 /** @private **/
69 public function BezierPlugin() {
70 super();
71 this.propName = "bezier"; //name of the special property that the plugin should intercept/manage
72 this.overwriteProps = []; //will be populated in init()
73 }
74
75 /** @private **/
76 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
77 if (!(value is Array)) {
78 return false;
79 }
80 init(tween, value as Array, false);
81 return true;
82 }
83
84 /** @private **/
85 protected function init(tween:TweenLite, beziers:Array, through:Boolean):void {
86 _target = tween.target;
87 var enumerables:Object = (tween.vars.isTV == true) ? tween.vars.exposedVars : tween.vars; //for TweenLiteVars and TweenMaxVars (we need an object with enumerable properties);
88 if (enumerables.orientToBezier == true) {
89 _orientData = [["x", "y", "rotation", 0, 0.01]];
90 _orient = true;
91 } else if (enumerables.orientToBezier is Array) {
92 _orientData = enumerables.orientToBezier;
93 _orient = true;
94 }
95 var props:Object = {}, i:int, p:String, killVarsLookup:Object;
96 for (i = 0; i < beziers.length; i++) {
97 for (p in beziers[i]) {
98 if (props[p] == undefined) {
99 props[p] = [tween.target[p]];
100 }
101 if (typeof(beziers[i][p]) == "number") {
102 props[p].push(beziers[i][p]);
103 } else {
104 props[p].push(tween.target[p] + Number(beziers[i][p])); //relative value
105 }
106 }
107 }
108 for (p in props) {
109 this.overwriteProps[this.overwriteProps.length] = p;
110 if (enumerables[p] != undefined) {
111 if (typeof(enumerables[p]) == "number") {
112 props[p].push(enumerables[p]);
113 } else {
114 props[p].push(tween.target[p] + Number(enumerables[p])); //relative value
115 }
116 killVarsLookup = {};
117 killVarsLookup[p] = true;
118 tween.killVars(killVarsLookup, false);
119 delete enumerables[p]; //in case TweenLite/Max hasn't reached the enumerable yet in its init() function. This prevents normal tweens from getting created for the properties that should be controled with the BezierPlugin.
120 }
121 }
122 _beziers = parseBeziers(props, through);
123 }
124
125 /**
126 * Helper method for translating control points into bezier information.
127 *
128 * @param props Object containing a property corresponding to each one you'd like bezier paths for. Each property's value should be a single Array with the numeric point values (i.e. <code>props.x = [12,50,80]</code> and <code>props.y = [50,97,158]</code>).
129 * @param through If you want the paths drawn THROUGH the supplied control points, set this to true.
130 * @return A new object with an Array of values for each property. The first element in the Array is the start value, the second is the control point, and the 3rd is the end value. (i.e. <code>returnObject.x = [[12, 32, 50}, [50, 65, 80]]</code>)
131 */
132 public static function parseBeziers(props:Object, through:Boolean=false):Object {
133 var i:int, a:Array, b:Object, p:String;
134 var all:Object = {};
135 if (through) {
136 for (p in props) {
137 a = props[p];
138 all[p] = b = [];
139 if (a.length > 2) {
140 b[b.length] = [a[0], a[1] - ((a[2] - a[0]) / 4), a[1]];
141 for (i = 1; i < a.length - 1; i++) {
142 b[b.length] = [a[i], a[i] + (a[i] - b[i - 1][1]), a[i + 1]];
143 }
144 } else {
145 b[b.length] = [a[0], (a[0] + a[1]) / 2, a[1]];
146 }
147 }
148 } else {
149 for (p in props) {
150 a = props[p];
151 all[p] = b = [];
152 if (a.length > 3) {
153 b[b.length] = [a[0], a[1], (a[1] + a[2]) / 2];
154 for (i = 2; i < a.length - 2; i++) {
155 b[b.length] = [b[i - 2][2], a[i], (a[i] + a[i + 1]) / 2];
156 }
157 b[b.length] = [b[b.length - 1][2], a[a.length - 2], a[a.length - 1]];
158 } else if (a.length == 3) {
159 b[b.length] = [a[0], a[1], a[2]];
160 } else if (a.length == 2) {
161 b[b.length] = [a[0], (a[0] + a[1]) / 2, a[1]];
162 }
163 }
164 }
165 return all;
166 }
167
168 /** @private **/
169 override public function killProps(lookup:Object):void {
170 for (var p:String in _beziers) {
171 if (p in lookup) {
172 delete _beziers[p];
173 }
174 }
175 super.killProps(lookup);
176 }
177
178 /** @private **/
179 override public function set changeFactor(n:Number):void {
180 var i:int, p:String, b:Object, t:Number, segments:uint, val:Number;
181 _changeFactor = n;
182 if (n == 1) { //to make sure the end values are EXACTLY what they need to be.
183 for (p in _beziers) {
184 i = _beziers[p].length - 1;
185 _target[p] = _beziers[p][i][2];
186 }
187 } else {
188 for (p in _beziers) {
189 segments = _beziers[p].length;
190 if (n < 0) {
191 i = 0;
192 } else if (n >= 1) {
193 i = segments - 1;
194 } else {
195 i = int(segments * n);
196 }
197 t = (n - (i * (1 / segments))) * segments;
198 b = _beziers[p][i];
199 if (this.round) {
200 val = b[0] + t * (2 * (1 - t) * (b[1] - b[0]) + t * (b[2] - b[0]));
201 _target[p] = (val > 0) ? int(val + 0.5) : int(val - 0.5); //4 times as fast as Math.round()
202 } else {
203 _target[p] = b[0] + t * (2 * (1 - t) * (b[1] - b[0]) + t * (b[2] - b[0]));
204 }
205 }
206 }
207
208 if (_orient) {
209 i = _orientData.length;
210 var curVals:Object = {}, dx:Number, dy:Number, cotb:Array, toAdd:Number;
211 while (i--) {
212 cotb = _orientData[i]; //current orientToBezier Array
213 curVals[cotb[0]] = _target[cotb[0]];
214 curVals[cotb[1]] = _target[cotb[1]];
215 }
216
217 var oldTarget:Object = _target, oldRound:Boolean = this.round;
218 _target = _future;
219 this.round = false;
220 _orient = false;
221 i = _orientData.length;
222 while (i--) {
223 cotb = _orientData[i]; //current orientToBezier Array
224 this.changeFactor = n + (cotb[4] || 0.01);
225 toAdd = cotb[3] || 0;
226 dx = _future[cotb[0]] - curVals[cotb[0]];
227 dy = _future[cotb[1]] - curVals[cotb[1]];
228 oldTarget[cotb[2]] = Math.atan2(dy, dx) * _RAD2DEG + toAdd;
229 }
230 _target = oldTarget;
231 this.round = oldRound;
232 _orient = true;
233 }
234
235 }
236
237 }
238 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.12
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 /**
10 * Identical to bezier except that instead of defining bezier control point values, you
11 * define points through which the bezier values should move. This can be more intuitive
12 * than using control points. Simply pass as many objects in the bezier Array as you'd like,
13 * one for each point through which the values should travel. For example, if you want the
14 * curved motion path to travel through the coordinates x:250, y:100 and x:50, y:200 and then
15 * end up at 500, 100, you'd do: <br /><br />
16 *
17 * <code>TweenLite.to(mc, 2, {bezierThrough:[{x:250, y:100}, {x:50, y:200}, {x:500, y:200}]});</code><br /><br />
18 *
19 * Keep in mind that you can bezierThrough tween ANY properties, not just x/y. <br /><br />
20 *
21 * Also, if you'd like to rotate the target in the direction of the bezier path,
22 * use the orientToBezier special property. In order to alter a rotation property accurately,
23 * TweenLite/Max needs 5 pieces of information:
24 * <ol>
25 * <li> Position property 1 (typically <code>"x"</code>)</li>
26 * <li> Position property 2 (typically <code>"y"</code>)</li>
27 * <li> Rotational property (typically <code>"rotation"</code>)</li>
28 * <li> Number of degrees to add (optional - makes it easy to orient your MovieClip properly)</li>
29 * <li> Tolerance (default is 0.01, but increase this if the rotation seems to jitter during the tween)</li>
30 * </ol><br />
31 *
32 * The orientToBezier property should be an Array containing one Array for each set of these values.
33 * For maximum flexibility, you can pass in any number of arrays inside the container array, one
34 * for each rotational property. This can be convenient when working in 3D because you can rotate
35 * on multiple axis. If you're doing a standard 2D x/y tween on a bezier, you can simply pass
36 * in a boolean value of true and TweenLite/Max will use a typical setup, <code>[["x", "y", "rotation", 0, 0.01]]</code>.
37 * Hint: Don't forget the container Array (notice the double outer brackets) <br /><br />
38 *
39 * <b>USAGE:</b><br /><br />
40 * <code>
41 * import com.greensock.TweenLite; <br />
42 * import com.greensock.plugins.TweenPlugin; <br />
43 * import com.greensock.plugins.BezierThroughPlugin; <br />
44 * TweenPlugin.activate([BezierThroughPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
45 *
46 * TweenLite.to(mc, 2, {bezierThrough:[{x:250, y:100}, {x:50, y:200}, {x:500, y:200}]}); <br /><br />
47 * </code>
48 *
49 * <b>Copyright 2010, 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.
50 *
51 * @author Jack Doyle, jack@greensock.com
52 */
53 public class BezierThroughPlugin extends BezierPlugin {
54 /** @private **/
55 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
56
57 /** @private **/
58 public function BezierThroughPlugin() {
59 super();
60 this.propName = "bezierThrough"; //name of the special property that the plugin should intercept/manage
61 }
62
63 /** @private **/
64 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
65 if (!(value is Array)) {
66 return false;
67 }
68 init(tween, value as Array, true);
69 return true;
70 }
71
72 }
73 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.0
3 * DATE: 8/18/2009
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com
6 **/
7 package com.greensock.plugins {
8 import flash.filters.*;
9 import flash.display.*;
10 import com.greensock.*;
11 /**
12 * Tweens a BlurFilter. The following properties are available (you only need to define the ones you want to tween):
13 * <code>
14 * <ul>
15 * <li> blurX : Number [0]</li>
16 * <li> blurY : Number [0]</li>
17 * <li> quality : uint [2]</li>
18 * <li> index : uint</li>
19 * <li> addFilter : Boolean [false]</li>
20 * <li> remove : Boolean [false]</li>
21 * </ul>
22 * </code>
23 *
24 * Set <code>remove</code> to true if you want the filter to be removed when the tween completes. <br /><br />
25 *
26 * <b>USAGE:</b><br /><br />
27 * <code>
28 * import com.greensock.TweenLite; <br />
29 * import com.greensock.plugins.TweenPlugin; <br />
30 * import com.greensock.plugins.BlurFilterPlugin; <br />
31 * TweenPlugin.activate([BlurFilterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
32 *
33 * TweenLite.to(mc, 1, {blurFilter:{blurX:10, blurY:10}}); <br /><br />
34 * </code>
35 *
36 * <b>Copyright 2010, 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.
37 *
38 * @author Jack Doyle, jack@greensock.com
39 */
40 public class BlurFilterPlugin extends FilterPlugin {
41 /** @private **/
42 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
43 /** @private **/
44 private static var _propNames:Array = ["blurX","blurY","quality"];
45
46 /** @private **/
47 public function BlurFilterPlugin() {
48 super();
49 this.propName = "blurFilter";
50 this.overwriteProps = ["blurFilter"];
51 }
52
53 /** @private **/
54 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
55 _target = target;
56 _type = BlurFilter;
57 initFilter(value, new BlurFilter(0, 0, value.quality || 2), _propNames);
58 return true;
59 }
60
61 }
62 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 2010-06-29
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
10 import flash.display.DisplayObject;
11 /**
12 * Forces the <code>cacheAsBitmap</code> property of a DisplayObject to be a certain value (<code>true</code> or <code>false</code>)
13 * during the tween and then sets it back to whatever it was before the tween was rendered for the first time. This <i>can</i> improve
14 * performance in certain situations, like when the DisplayObject <strong>NOT</strong> tweening its rotation, scaleX, scaleY, or similar
15 * things with its <code>transform.matrix</code>. See Adobe's docs for details about when it is appropriate to set <code>cacheAsBitmap</code>
16 * to <code>true</code>. Also beware that whenever a DisplayObject's <code>cacheAsBitmap</code> is <code>true</code>, it will ONLY be
17 * rendered on whole pixel values which can lead to animation that looks "choppy" at slow speeds.<br /><br />
18 *
19 * For example, if you want to set <code>cacheAsBitmap</code> to <code>true</code> while the tween is running, do:<br /><br /><code>
20 *
21 * TweenLite.to(mc, 1, {x:100, cacheAsBitmap:true});<br /><br /></code>
22 *
23 * <b>USAGE:</b><br /><br />
24 * <code>
25 * import com.greensock.TweenLite; <br />
26 * import com.greensock.plugins.TweenPlugin; <br />
27 * import com.greensock.plugins.CacheAsBitmapPlugin; <br />
28 * TweenPlugin.activate([CacheAsBitmapPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
29 *
30 * TweenLite.to(mc, 1, {x:100, cacheAsBitmap:true}); <br /><br />
31 * </code>
32 *
33 * <b>Copyright 2010, 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.
34 *
35 * @author Jack Doyle, jack@greensock.com
36 */
37 public class CacheAsBitmapPlugin extends TweenPlugin {
38 /** @private **/
39 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
40
41 /** @private **/
42 protected var _target:DisplayObject;
43 /** @private **/
44 protected var _tween:TweenLite;
45 /** @private **/
46 protected var _cacheAsBitmap:Boolean;
47 /** @private **/
48 protected var _initVal:Boolean;
49
50 /** @private **/
51 public function CacheAsBitmapPlugin() {
52 super();
53 this.propName = "cacheAsBitmap";
54 this.overwriteProps = ["cacheAsBitmap"];
55 }
56
57 /** @private **/
58 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
59 _target = target as DisplayObject;
60 _tween = tween;
61 _initVal = _target.cacheAsBitmap;
62 _cacheAsBitmap = Boolean(value);
63 return true;
64 }
65
66 /** @private **/
67 override public function set changeFactor(n:Number):void {
68 if (_tween.cachedDuration == _tween.cachedTime || _tween.cachedTime == 0) { //a changeFactor of 1 doesn't necessarily mean the tween is done - if the ease is Elastic.easeOut or Back.easeOut for example, they could hit 1 mid-tween.
69 _target.cacheAsBitmap = _initVal;
70 } else if (_target.cacheAsBitmap != _cacheAsBitmap) {
71 _target.cacheAsBitmap = _cacheAsBitmap;
72 }
73 }
74
75 }
76 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.2 (beta)
3 * DATE: 2010-04-16
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.GreenSock.com
6 **/
7 package com.greensock.plugins {
8 import com.greensock.*;
9 import com.greensock.motionPaths.CirclePath2D;
10 import com.greensock.motionPaths.PathFollower;
11
12 import flash.display.*;
13 import flash.geom.Matrix;
14 /**
15 * Tweens an object along a CirclePath2D motion path in any direction (clockwise, counter-clockwise, or shortest).
16 * The plugin recognizes the following properties:
17 * <ul>
18 * <li><b>path</b> : CirclePath2D - The CirclePath2D instance to follow (com.greensock.motionPaths.CirclePath2D)</li>
19 * <li><b>startAngle</b> : Number - The position at which the target should begin its rotation (described
20 * in degrees unless useRadians is true in which case it is described in radians).
21 * For example, to begin at the top of the circle, use 270 or -90 as the startAngle.</li>
22 * <li><b>endAngle</b> : Number - The position at which the target should end its rotation (described in
23 * degrees unless useRadians is true in which case it is described in radians).
24 * For example, to end at the bottom of the circle, use 90 as the endAngle</li>
25 * <li><b>autoRotate</b> : Boolean - When <code>autoRotate</code> is <code>true</code>, the target will automatically
26 * be rotated so that it is oriented to the angle of the path. To offset this value (like to always add
27 * 90 degrees for example), use the <code>rotationOffset</code> property.</li>
28 * <li><b>rotationOffset</b> : Number - When <code>autoRotate</code> is <code>true</code>, this value will always
29 * be added to the resulting <code>rotation</code> of the target.</li>
30 * <li><b>direction</b> : String - The direction in which the target should travel around the path. Options are
31 * <code>Direction.CLOCKWISE</code> ("clockwise"), <code>Direction.COUNTER_CLOCKWISE</code>
32 * ("counterClockwise"), or <code>Direction.SHORTEST</code> ("shortest").</li>
33 * <li><b>extraRevolutions</b> : uint - If instead of going directly to the endAngle, you want the target to
34 * travel one or more extra revolutions around the path before going to the endAngle,
35 * define that number of revolutions here. </li>
36 * <li><b>useRadians</b> : Boolean - If you prefer to define values in radians instead of degrees, set useRadians to true.</li>
37 * </ul>
38 *
39 * <br /><br />
40 *
41 * <b>USAGE:</b><br /><br />
42 * <code>
43 * import com.greensock.~~; <br />
44 * import com.greensock.plugins.~~; <br />
45 * import com.greensock.motionPaths.~~<br />
46 * TweenPlugin.activate([CirclePath2DPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
47 *
48 * var circle:CirclePath2D = new CirclePath2D(150, 150, 100);
49 * TweenLite.to(mc, 2, {circlePath2D:{path:circle, startAngle:90, endAngle:270, direction:Direction.CLOCKWISE, extraRevolutions:2}}); <br /><br />
50 * </code>
51 *
52 * <b>Copyright 2010, 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.
53 *
54 * @author Jack Doyle, jack@greensock.com
55 */
56 public class CirclePath2DPlugin extends TweenPlugin {
57 /** @private **/
58 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
59 /** @private **/
60 private static const _2PI:Number = Math.PI * 2;
61 /** @private **/
62 private static const _RAD2DEG:Number = 180 / Math.PI;
63
64 /** @private **/
65 protected var _target:Object;
66 /** @private **/
67 protected var _autoRemove:Boolean;
68 /** @private **/
69 protected var _start:Number;
70 /** @private **/
71 protected var _change:Number;
72 /** @private **/
73 protected var _circle:CirclePath2D;
74 /** @private **/
75 protected var _autoRotate:Boolean;
76 /** @private **/
77 protected var _rotationOffset:Number;
78
79 /** @private **/
80 public function CirclePath2DPlugin() {
81 super();
82 this.propName = "circlePath2D";
83 this.overwriteProps = ["x","y"];
84 }
85
86 /** @private **/
87 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
88 if (!("path" in value) || !(value.path is CirclePath2D)) {
89 trace("CirclePath2DPlugin error: invalid 'path' property. Please define a CirclePath2D instance.");
90 return false;
91 }
92 _target = target;
93 _circle = value.path as CirclePath2D;
94 _autoRotate = Boolean(value.autoRotate == true);
95 _rotationOffset = value.rotationOffset || 0;
96
97 var f:PathFollower = _circle.getFollower(target);
98 if (f != null && !("startAngle" in value)) {
99 _start = f.progress;
100 } else {
101 _start = _circle.angleToProgress(value.startAngle || 0, value.useRadians);
102 _circle.renderObjectAt(_target, _start);
103 }
104 _change = Number(_circle.anglesToProgressChange(_circle.progressToAngle(_start), value.endAngle || 0, value.direction || "clockwise", value.extraRevolutions || 0, Boolean(value.useRadians)));
105 return true;
106 }
107
108 /** @private **/
109 override public function killProps(lookup:Object):void {
110 super.killProps(lookup);
111 if (("x" in lookup) || ("y" in lookup)) {
112 this.overwriteProps = [];
113 }
114 }
115
116 /** @private **/
117 override public function set changeFactor(n:Number):void {
118 var angle:Number = (_start + (_change * n)) * _2PI;
119 var radius:Number = _circle.radius;
120 var m:Matrix = _circle.transform.matrix;
121 var px:Number = Math.cos(angle) * radius;
122 var py:Number = Math.sin(angle) * radius;
123 _target.x = px * m.a + py * m.c + m.tx;
124 _target.y = px * m.b + py * m.d + m.ty;
125
126 if (_autoRotate) {
127 angle += Math.PI / 2;
128 px = Math.cos(angle) * _circle.radius;
129 py = Math.sin(angle) * _circle.radius;
130 _target.rotation = Math.atan2(px * m.b + py * m.d, px * m.a + py * m.c) * _RAD2DEG + _rotationOffset;
131 }
132 }
133
134 }
135 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.0
3 * DATE: 8/18/2009
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com
6 **/
7 package com.greensock.plugins {
8 import flash.display.*;
9 import flash.filters.*;
10 import com.greensock.*;
11 /**
12 * ColorMatrixFilter tweening offers an easy way to tween a DisplayObject's saturation, hue, contrast,
13 * brightness, and colorization. The following properties are available (you only need to define the ones you want to tween):
14 * <ul>
15 * <li><code> colorize : uint </code> (colorizing a DisplayObject makes it look as though you're seeing it through a colored piece of glass whereas tinting it makes every pixel exactly that color. You can control the amount of colorization using the "amount" value where 1 is full strength, 0.5 is half-strength, and 0 has no colorization effect.)</li>
16 * <li><code> amount : Number [1] </code> (only used in conjunction with "colorize")</li>
17 * <li><code> contrast : Number </code> (1 is normal contrast, 0 has no contrast, and 2 is double the normal contrast, etc.)</li>
18 * <li><code> saturation : Number </code> (1 is normal saturation, 0 makes the DisplayObject look black and white, and 2 would be double the normal saturation)</li>
19 * <li><code> hue : Number </code> (changes the hue of every pixel. Think of it as degrees, so 180 would be rotating the hue to be exactly opposite as normal, 360 would be the same as 0, etc.)</li>
20 * <li><code> brightness : Number </code> (1 is normal brightness, 0 is much darker than normal, and 2 is twice the normal brightness, etc.)</li>
21 * <li><code> threshold : Number </code> (number from 0 to 255 that controls the threshold of where the pixels turn white or black)</li>
22 * <li><code> matrix : Array </code> (If you already have a matrix from a ColorMatrixFilter that you want to tween to, pass it in with the "matrix" property. This makes it possible to match effects created in the Flash IDE.)</li>
23 * <li><code> index : Number </code> (only necessary if you already have a filter applied and you want to target it with the tween.)</li>
24 * <li><code> addFilter : Boolean [false] </code></li>
25 * <li><code> remove : Boolean [false] </code> (Set remove to true if you want the filter to be removed when the tween completes.)</li>
26 * </ul>
27 * HINT: If you'd like to match the ColorMatrixFilter values you created in the Flash IDE on a particular object, you can get its matrix like this:<br /><br /><code>
28 *
29 * import flash.display.DisplayObject; <br />
30 * import flash.filters.ColorMatrixFilter; <br /><br />
31 *
32 * function getColorMatrix(mc:DisplayObject):Array { <br />
33 * var f:Array = mc.filters, i:uint; <br />
34 * for (i = 0; i &lt; f.length; i++) { <br />
35 * if (f[i] is ColorMatrixFilter) { <br />
36 * return f[i].matrix; <br />
37 * } <br />
38 * } <br />
39 * return null; <br />
40 * } <br /><br />
41 *
42 * var myOriginalMatrix:Array = getColorMatrix(my_mc); //store it so you can tween back to it anytime like TweenMax.to(my_mc, 1, {colorMatrixFilter:{matrix:myOriginalMatrix}});
43 * </code>
44 * <br /><br />
45 *
46 * <b>USAGE:</b><br /><br />
47 * <code>
48 * import com.greensock.TweenLite; <br />
49 * import com.greensock.plugins.TweenPlugin; <br />
50 * import com.greensock.plugins.ColorMatrixFilterPlugin; <br />
51 * TweenPlugin.activate([ColorMatrixFilterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
52 *
53 * TweenLite.to(mc, 1, {colorMatrixFilter:{colorize:0xFF0000}}); <br /><br />
54 * </code>
55 *
56 * <b>Copyright 2010, 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.
57 *
58 * @author Jack Doyle, jack@greensock.com
59 */
60 public class ColorMatrixFilterPlugin extends FilterPlugin {
61 /** @private **/
62 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
63 /** @private **/
64 private static var _propNames:Array = [];
65
66 /** @private **/
67 protected static var _idMatrix:Array = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];
68 /** @private **/
69 protected static var _lumR:Number = 0.212671; //Red constant - used for a few color matrix filter functions
70 /** @private **/
71 protected static var _lumG:Number = 0.715160; //Green constant - used for a few color matrix filter functions
72 /** @private **/
73 protected static var _lumB:Number = 0.072169; //Blue constant - used for a few color matrix filter functions
74
75 /** @private **/
76 protected var _matrix:Array;
77 /** @private **/
78 protected var _matrixTween:EndArrayPlugin;
79
80 /** @private **/
81 public function ColorMatrixFilterPlugin() {
82 super();
83 this.propName = "colorMatrixFilter";
84 this.overwriteProps = ["colorMatrixFilter"];
85 }
86
87 /** @private **/
88 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
89 _target = target;
90 _type = ColorMatrixFilter;
91 var cmf:Object = value;
92 initFilter({remove:value.remove, index:value.index, addFilter:value.addFilter}, new ColorMatrixFilter(_idMatrix.slice()), _propNames);
93 _matrix = ColorMatrixFilter(_filter).matrix;
94 var endMatrix:Array = [];
95 if (cmf.matrix != null && (cmf.matrix is Array)) {
96 endMatrix = cmf.matrix;
97 } else {
98 if (cmf.relative == true) {
99 endMatrix = _matrix.slice();
100 } else {
101 endMatrix = _idMatrix.slice();
102 }
103 endMatrix = setBrightness(endMatrix, cmf.brightness);
104 endMatrix = setContrast(endMatrix, cmf.contrast);
105 endMatrix = setHue(endMatrix, cmf.hue);
106 endMatrix = setSaturation(endMatrix, cmf.saturation);
107 endMatrix = setThreshold(endMatrix, cmf.threshold);
108 if (!isNaN(cmf.colorize)) {
109 endMatrix = colorize(endMatrix, cmf.colorize, cmf.amount);
110 }
111 }
112 _matrixTween = new EndArrayPlugin();
113 _matrixTween.init(_matrix, endMatrix);
114 return true;
115 }
116
117 /** @private **/
118 override public function set changeFactor(n:Number):void {
119 _matrixTween.changeFactor = n;
120 ColorMatrixFilter(_filter).matrix = _matrix;
121 super.changeFactor = n;
122 }
123
124
125 //---- MATRIX OPERATIONS --------------------------------------------------------------------------------
126
127 /** @private **/
128 public static function colorize(m:Array, color:Number, amount:Number = 1):Array {
129 if (isNaN(color)) {
130 return m;
131 } else if (isNaN(amount)) {
132 amount = 1;
133 }
134 var r:Number = ((color >> 16) & 0xff) / 255;
135 var g:Number = ((color >> 8) & 0xff) / 255;
136 var b:Number = (color & 0xff) / 255;
137 var inv:Number = 1 - amount;
138 var temp:Array = [inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0,
139 amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0,
140 amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0,
141 0, 0, 0, 1, 0];
142 return applyMatrix(temp, m);
143 }
144
145 /** @private **/
146 public static function setThreshold(m:Array, n:Number):Array {
147 if (isNaN(n)) {
148 return m;
149 }
150 var temp:Array = [_lumR * 256, _lumG * 256, _lumB * 256, 0, -256 * n,
151 _lumR * 256, _lumG * 256, _lumB * 256, 0, -256 * n,
152 _lumR * 256, _lumG * 256, _lumB * 256, 0, -256 * n,
153 0, 0, 0, 1, 0];
154 return applyMatrix(temp, m);
155 }
156
157 /** @private **/
158 public static function setHue(m:Array, n:Number):Array {
159 if (isNaN(n)) {
160 return m;
161 }
162 n *= Math.PI / 180;
163 var c:Number = Math.cos(n);
164 var s:Number = Math.sin(n);
165 var temp:Array = [(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1];
166 return applyMatrix(temp, m);
167 }
168
169 /** @private **/
170 public static function setBrightness(m:Array, n:Number):Array {
171 if (isNaN(n)) {
172 return m;
173 }
174 n = (n * 100) - 100;
175 return applyMatrix([1,0,0,0,n,
176 0,1,0,0,n,
177 0,0,1,0,n,
178 0,0,0,1,0,
179 0,0,0,0,1], m);
180 }
181
182 /** @private **/
183 public static function setSaturation(m:Array, n:Number):Array {
184 if (isNaN(n)) {
185 return m;
186 }
187 var inv:Number = 1 - n;
188 var r:Number = inv * _lumR;
189 var g:Number = inv * _lumG;
190 var b:Number = inv * _lumB;
191 var temp:Array = [r + n, g , b , 0, 0,
192 r , g + n, b , 0, 0,
193 r , g , b + n, 0, 0,
194 0 , 0 , 0 , 1, 0];
195 return applyMatrix(temp, m);
196 }
197
198 /** @private **/
199 public static function setContrast(m:Array, n:Number):Array {
200 if (isNaN(n)) {
201 return m;
202 }
203 n += 0.01;
204 var temp:Array = [n,0,0,0,128 * (1 - n),
205 0,n,0,0,128 * (1 - n),
206 0,0,n,0,128 * (1 - n),
207 0,0,0,1,0];
208 return applyMatrix(temp, m);
209 }
210
211 /** @private **/
212 public static function applyMatrix(m:Array, m2:Array):Array {
213 if (!(m is Array) || !(m2 is Array)) {
214 return m2;
215 }
216 var temp:Array = [], i:int = 0, z:int = 0, y:int, x:int;
217 for (y = 0; y < 4; y++) {
218 for (x = 0; x < 5; x++) {
219 if (x == 4) {
220 z = m[i + 4];
221 } else {
222 z = 0;
223 }
224 temp[i + x] = m[i] * m2[x] +
225 m[i+1] * m2[x + 5] +
226 m[i+2] * m2[x + 10] +
227 m[i+3] * m2[x + 15] +
228 z;
229 }
230 i += 5;
231 }
232 return temp;
233 }
234
235 }
236 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.52
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 flash.display.*;
9 import flash.geom.ColorTransform;
10 import com.greensock.*;
11 /**
12 * Ever wanted to tween ColorTransform properties of a DisplayObject to do advanced effects like overexposing, altering
13 * the brightness or setting the percent/amount of tint? Or maybe tween individual ColorTransform
14 * properties like redMultiplier, redOffset, blueMultiplier, blueOffset, etc. ColorTransformPlugin gives you an easy way to
15 * do just that. <br /><br />
16 *
17 * <b>PROPERTIES:</b><br />
18 * <ul>
19 * <li><code> tint (or color) : uint</code> - Color of the tint. Use a hex value, like 0xFF0000 for red.</li>
20 * <li><code> tintAmount : Number</code> - Number between 0 and 1. Works with the "tint" property and indicats how much of an effect the tint should have. 0 makes the tint invisible, 0.5 is halfway tinted, and 1 is completely tinted.</li>
21 * <li><code> brightness : Number</code> - Number between 0 and 2 where 1 is normal brightness, 0 is completely dark/black, and 2 is completely bright/white</li>
22 * <li><code> exposure : Number</code> - Number between 0 and 2 where 1 is normal exposure, 0, is completely underexposed, and 2 is completely overexposed. Overexposing an object is different then changing the brightness - it seems to almost bleach the image and looks more dynamic and interesting (subjectively speaking).</li>
23 * <li><code> redOffset : Number</code></li>
24 * <li><code> greenOffset : Number</code></li>
25 * <li><code> blueOffset : Number</code></li>
26 * <li><code> alphaOffset : Number</code></li>
27 * <li><code> redMultiplier : Number</code></li>
28 * <li><code> greenMultiplier : Number</code></li>
29 * <li><code> blueMultiplier : Number</code></li>
30 * <li><code> alphaMultiplier : Number</code> </li>
31 * </ul><br /><br />
32 *
33 * <b>USAGE:</b><br /><br />
34 * <code>
35 * import com.greensock.TweenLite; <br />
36 * import com.greensock.plugins.TweenPlugin; <br />
37 * import com.greensock.plugins.ColorTransformPlugin; <br />
38 * TweenPlugin.activate([ColorTransformPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
39 *
40 * TweenLite.to(mc, 1, {colorTransform:{tint:0xFF0000, tintAmount:0.5}}); <br /><br />
41 * </code>
42 *
43 * <b>Copyright 2010, 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.
44 *
45 * @author Jack Doyle, jack@greensock.com
46 */
47 public class ColorTransformPlugin extends TintPlugin {
48 /** @private **/
49 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
50
51 /** @private **/
52 public function ColorTransformPlugin() {
53 super();
54 this.propName = "colorTransform";
55 }
56
57 /** @private **/
58 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
59 if (!(target is DisplayObject)) {
60 return false;
61 }
62 var end:ColorTransform = target.transform.colorTransform;
63 for (var p:String in value) {
64 if (p == "tint" || p == "color") {
65 if (value[p] != null) {
66 end.color = int(value[p]);
67 }
68 } else if (p == "tintAmount" || p == "exposure" || p == "brightness") {
69 //handle this later...
70 } else {
71 end[p] = value[p];
72 }
73 }
74
75 if (!isNaN(value.tintAmount)) {
76 var ratio:Number = value.tintAmount / (1 - ((end.redMultiplier + end.greenMultiplier + end.blueMultiplier) / 3));
77 end.redOffset *= ratio;
78 end.greenOffset *= ratio;
79 end.blueOffset *= ratio;
80 end.redMultiplier = end.greenMultiplier = end.blueMultiplier = 1 - value.tintAmount;
81 } else if (!isNaN(value.exposure)) {
82 end.redOffset = end.greenOffset = end.blueOffset = 255 * (value.exposure - 1);
83 end.redMultiplier = end.greenMultiplier = end.blueMultiplier = 1;
84 } else if (!isNaN(value.brightness)) {
85 end.redOffset = end.greenOffset = end.blueOffset = Math.max(0, (value.brightness - 1) * 255);
86 end.redMultiplier = end.greenMultiplier = end.blueMultiplier = 1 - Math.abs(value.brightness - 1);
87 }
88
89 _ignoreAlpha = Boolean(tween.vars.alpha != undefined && value.alphaMultiplier == undefined);
90
91 init(target as DisplayObject, end);
92
93 return true;
94 }
95
96 }
97 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 2.0
3 * DATE: 8/18/2009
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://www.TweenMax.com
6 **/
7 package com.greensock.plugins {
8 import flash.filters.*;
9 import flash.display.*;
10 import com.greensock.*;
11 /**
12 * Tweens a DropShadowFilter. The following properties are available (you only need to define the ones you want to tween):
13 * <code>
14 * <ul>
15 * <li> distance : Number [0]</li>
16 * <li> angle : Number [45]</li>
17 * <li> color : uint [0x000000]</li>
18 * <li> alpha :Number [0]</li>
19 * <li> blurX : Number [0]</li>
20 * <li> blurY : Number [0]</li>
21 * <li> strength : Number [1]</li>
22 * <li> quality : uint [2]</li>
23 * <li> inner : Boolean [false]</li>
24 * <li> knockout : Boolean [false]</li>
25 * <li> hideObject : Boolean [false]</li>
26 * <li> index : uint</li>
27 * <li> addFilter : Boolean [false]</li>
28 * <li> remove : Boolean [false]</li>
29 * </ul>
30 * </code>
31 * Set <code>remove</code> to true if you want the filter to be removed when the tween completes. <br /><br />
32 *
33 * <b>USAGE:</b><br /><br />
34 * <code>
35 * import com.greensock.TweenLite; <br />
36 * import com.greensock.plugins.TweenPlugin; <br />
37 * import com.greensock.plugins.DropShadowFilterPlugin; <br />
38 * TweenPlugin.activate([DropShadowFilterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
39 *
40 * TweenLite.to(mc, 1, {dropShadowFilter:{blurX:5, blurY:5, distance:5, alpha:0.6}}); <br /><br />
41 * </code>
42 *
43 * <b>Copyright 2010, 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.
44 *
45 * @author Jack Doyle, jack@greensock.com
46 */
47 public class DropShadowFilterPlugin extends FilterPlugin {
48 /** @private **/
49 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
50 /** @private **/
51 private static var _propNames:Array = ["distance","angle","color","alpha","blurX","blurY","strength","quality","inner","knockout","hideObject"];
52
53 /** @private **/
54 public function DropShadowFilterPlugin() {
55 super();
56 this.propName = "dropShadowFilter";
57 this.overwriteProps = ["dropShadowFilter"];
58 }
59
60 /** @private **/
61 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
62 _target = target;
63 _type = DropShadowFilter;
64 initFilter(value, new DropShadowFilter(0, 45, 0x000000, 0, 0, 0, 1, value.quality || 2, value.inner, value.knockout, value.hideObject), _propNames);
65 return true;
66 }
67
68 }
69 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 1.6
3 * DATE: 10/19/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
10 import flash.display.*;
11 /**
12 * Tweens numbers in an Array. <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.EndArrayPlugin; <br />
19 * TweenPlugin.activate([EndArrayPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
20 *
21 * var myArray:Array = [1,2,3,4];<br />
22 * TweenLite.to(myArray, 1.5, {endArray:[10,20,30,40]}); <br /><br />
23 * </code>
24 *
25 * <b>Copyright 2010, 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.
26 *
27 * @author Jack Doyle, jack@greensock.com
28 */
29 public class EndArrayPlugin extends TweenPlugin {
30 /** @private **/
31 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
32
33 /** @private **/
34 protected var _a:Array;
35 /** @private **/
36 protected var _info:Array = [];
37
38 /** @private **/
39 public function EndArrayPlugin() {
40 super();
41 this.propName = "endArray"; //name of the special property that the plugin should intercept/manage
42 this.overwriteProps = ["endArray"];
43 }
44
45 /** @private **/
46 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
47 if (!(target is Array) || !(value is Array)) {
48 return false;
49 }
50 init(target as Array, value);
51 return true;
52 }
53
54 /** @private **/
55 public function init(start:Array, end:Array):void {
56 _a = start;
57 var i:int = end.length;
58 while (i--) {
59 if (start[i] != end[i] && start[i] != null) {
60 _info[_info.length] = new ArrayTweenInfo(i, _a[i], end[i] - _a[i]);
61 }
62 }
63 }
64
65 /** @private **/
66 override public function set changeFactor(n:Number):void {
67 var i:int = _info.length, ti:ArrayTweenInfo;
68 if (this.round) {
69 var val:Number;
70 while (i--) {
71 ti = _info[i];
72 val = ti.start + (ti.change * n);
73 _a[ti.index] = (val > 0) ? int(val + 0.5) : int(val - 0.5); //4 times as fast as Math.round()
74 }
75 } else {
76 while (i--) {
77 ti = _info[i];
78 _a[ti.index] = ti.start + (ti.change * n);
79 }
80 }
81 }
82
83 }
84 }
85
86 internal class ArrayTweenInfo {
87 public var index:uint;
88 public var start:Number;
89 public var change:Number;
90
91 public function ArrayTweenInfo(index:uint, start:Number, change:Number) {
92 this.index = index;
93 this.start = start;
94 this.change = change;
95 }
96 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 * VERSION: 0.9
3 * DATE: 10/22/2009
4 * ACTIONSCRIPT VERSION: 3.0
5 * UPDATES AND DOCUMENTATION AT: http://blog.greensock.com
6 **/
7 package com.greensock.plugins {
8 import com.greensock.*;
9
10 import flash.display.*;
11 /**
12 * Tweens numbers in an Vector.<Number>. Remember, Vectors require that you publish to <strong>Flash Player 10</strong> or later.<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.EndVectorPlugin; <br />
19 * TweenPlugin.activate([EndVectorPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.<br /><br />
20 *
21 * var v:Vector.<Number> = new Vector.<Number>();<br />
22 * v[0] = 0;<br />
23 * v[1] = 1;<br />
24 * v[2] = 2;<br />
25 * var end:Vector.<Number> = new Vector.<Number>();<br />
26 * end[0] = 100;<br />
27 * end[1] = 250;<br />
28 * end[2] = 500;<br />
29 * TweenLite.to(v, 3, {endVector:end, onUpdate:report}); <br />
30 * function report():void {<br />
31 * trace(v);<br />
32 * }<br /><br />
33 * </code>
34 *
35 * <b>Copyright 2010, 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.
36 *
37 * @author Jack Doyle, jack@greensock.com
38 */
39 public class EndVectorPlugin extends TweenPlugin {
40 /** @private **/
41 public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
42
43 /** @private **/
44 protected var _v:Vector.<Number>;
45 /** @private **/
46 protected var _info:Vector.<VectorInfo> = new Vector.<VectorInfo>();
47
48 /** @private **/
49 public function EndVectorPlugin() {
50 super();
51 this.propName = "endVector"; //name of the special property that the plugin should intercept/manage
52 this.overwriteProps = ["endVector"];
53 }
54
55 /** @private **/
56 override public function onInitTween(target:Object, value:*, tween:TweenLite):Boolean {
57 if (!(target is Vector.<Number>) || !(value is Vector.<Number>)) {
58 return false;
59 }
60 init(target as Vector.<Number>, value as Vector.<Number>);
61 return true;
62 }
63
64 /** @private **/
65 public function init(start:Vector.<Number>, end:Vector.<Number>):void {
66 _v = start;
67 var i:int = end.length, cnt:uint = 0;
68 while (i--) {
69 if (_v[i] != end[i]) {
70 _info[cnt++] = new VectorInfo(i, _v[i], end[i] - _v[i]);
71 }
72 }
73 }
74
75 /** @private **/
76 override public function set changeFactor(n:Number):void {
77 var i:int = _info.length, vi:VectorInfo;
78 if (this.round) {
79 var val:Number;
80 while (i--) {
81 vi = _info[i];
82 val = vi.start + (vi.change * n);
83 _v[vi.index] = (val > 0) ? int(val + 0.5) : int(val - 0.5); //4 times as fast as Math.round()
84 }
85 } else {
86 while (i--) {
87 vi = _info[i];
88 _v[vi.index] = vi.start + (vi.change * n);
89 }
90 }
91 }
92
93 }
94 }
95
96 internal class VectorInfo {
97 public var index:uint;
98 public var start:Number;
99 public var change:Number;
100
101 public function VectorInfo(index:uint, start:Number, change:Number) {
102 this.index = index;
103 this.start = start;
104 this.change = change;
105 }
106 }
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
No preview for this file type