michaelforrest-tidy 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/Manifest +87 -0
  2. data/README +5 -0
  3. data/Rakefile +14 -0
  4. data/bin/tidyproject +33 -0
  5. data/lib/aslibs/as3/lbi/com/lbi/animation/animator/Animator.as +86 -0
  6. data/lib/aslibs/as3/lbi/com/lbi/animation/animator/Transition.as +142 -0
  7. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Parallel.as +28 -0
  8. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Queue.as +93 -0
  9. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Sequence.as +28 -0
  10. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Set.as +82 -0
  11. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Stack.as +30 -0
  12. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Animation.as +173 -0
  13. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Message.as +36 -0
  14. data/lib/aslibs/as3/lbi/com/lbi/animation/single/MethodWithCompleteEvent.as +75 -0
  15. data/lib/aslibs/as3/lbi/com/lbi/animation/single/OrphanEvent.as +78 -0
  16. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Pause.as +35 -0
  17. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Tween.as +73 -0
  18. data/lib/aslibs/as3/lbi/com/lbi/animation/util/Easing.as +158 -0
  19. data/lib/aslibs/as3/lbi/com/lbi/animation/util/Engine.as +35 -0
  20. data/lib/aslibs/as3/lbi/com/lbi/animation/util/GroupCommon.as +62 -0
  21. data/lib/aslibs/as3/lbi/com/lbi/animation/util/IAnimation.as +30 -0
  22. data/lib/aslibs/as3/lbi/com/lbi/debug/DraggyClip.as +96 -0
  23. data/lib/aslibs/as3/lbi/com/lbi/debug/FPSView.as +48 -0
  24. data/lib/aslibs/as3/lbi/com/lbi/debug/KeySequenceTrigger.as +60 -0
  25. data/lib/aslibs/as3/lbi/com/lbi/debug/Log.as +168 -0
  26. data/lib/aslibs/as3/lbi/com/lbi/debug/LogItemType.as +23 -0
  27. data/lib/aslibs/as3/lbi/com/lbi/debug/LogType.as +31 -0
  28. data/lib/aslibs/as3/lbi/com/lbi/debug/ViewAnalysis.as +24 -0
  29. data/lib/aslibs/as3/lbi/com/lbi/media/IBufferable.as +16 -0
  30. data/lib/aslibs/as3/lbi/com/lbi/media/ITransportControllable.as +11 -0
  31. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Collection.as +296 -0
  32. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/ISearchable.as +10 -0
  33. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/ISelectable.as +10 -0
  34. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Matchable.as +9 -0
  35. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Searchable.as +56 -0
  36. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Selectable.as +49 -0
  37. data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/Cloner.as +15 -0
  38. data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/TypographyBase.as +194 -0
  39. data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/preloading/LoadProgressEvent.as +18 -0
  40. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Application.as +45 -0
  41. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/ConcurrentDependencyLoader.as +27 -0
  42. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/EventMapper.as +85 -0
  43. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Hyperlink.as +36 -0
  44. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/IEventMapper.as +10 -0
  45. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Merge.as +14 -0
  46. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/SequentialDependencyLoader.as +43 -0
  47. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/StringFormatting.as +142 -0
  48. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/XMLListLoader.as +98 -0
  49. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/XMLListLoaderDispatcher.as +52 -0
  50. data/lib/aslibs/as3/lbi/com/lbi/mvc/view/ViewBase.as +323 -0
  51. data/lib/aslibs/as3/lbi/com/quasimondo/geom/ColorMatrix.as +682 -0
  52. data/lib/script/as2/lib/as2_class.rb +37 -0
  53. data/lib/script/as2/lib/test/SampleClass.as +34 -0
  54. data/lib/script/as2/lib/test/as2_class_test.rb +15 -0
  55. data/lib/script/as2/navigation/bin/xml/__model.xml +7 -0
  56. data/lib/script/as2/navigation/navigation.rb +44 -0
  57. data/lib/script/as2/navigation/src/app/models/App.as +14 -0
  58. data/lib/script/as2/navigation/src/app/models/__Model.as +42 -0
  59. data/lib/script/as2/navigation/src/app/views/__model/__ModelView.as +61 -0
  60. data/lib/script/as2/navigation/src/app/views/__model/__ModelsView.as +33 -0
  61. data/lib/script/as2/project/project.rb +7 -0
  62. data/lib/script/as2/project/src/app/helpers/Colours.as +1 -0
  63. data/lib/script/as2/project/src/app/helpers/Typography.as +1 -0
  64. data/lib/script/as2/project/src/app/models/App.as +22 -0
  65. data/lib/script/as2/project/src/app/models/FlashVars.as +1 -0
  66. data/lib/script/as2/project/src/app/models/Linkages.as +8 -0
  67. data/lib/script/as2/project/src/app/views/AppView.as +21 -0
  68. data/lib/script/as3/project/project.rb +10 -0
  69. data/lib/script/as3/project/src/app/helpers/Colours.as +1 -0
  70. data/lib/script/as3/project/src/app/helpers/Typography.as +1 -0
  71. data/lib/script/as3/project/src/app/models/App.as +21 -0
  72. data/lib/script/as3/project/src/app/models/FlashVars.as +1 -0
  73. data/lib/script/as3/project/src/app/views/AppView.as +27 -0
  74. data/lib/script/as3/scaffold/bin/xml/__model.xml +0 -0
  75. data/lib/script/as3/scaffold/scaffold.rb +41 -0
  76. data/lib/script/as3/scaffold/src/models/__Model.as +11 -0
  77. data/lib/script/as3/scaffold/src/views/__model/__ModelDetailView.as +0 -0
  78. data/lib/script/as3/scaffold/src/views/__model/__ModelListItemView.as +0 -0
  79. data/lib/script/as3/scaffold/src/views/__model/__ModelListView.as +0 -0
  80. data/lib/script/bwlimit.rb +305 -0
  81. data/lib/script/generate +117 -0
  82. data/lib/script/server +4 -0
  83. data/lib/script/server.rb +20 -0
  84. data/lib/tidy_project.rb +19 -0
  85. data/tasks/build.rake +4 -0
  86. data/tasks/release.rake +8 -0
  87. data/test/test_tidy_project.rb +22 -0
  88. data/tidy.gemspec +33 -0
  89. metadata +229 -0
@@ -0,0 +1,173 @@
1
+ package com.lbi.animation.single {
2
+ import flash.events.Event;
3
+ import flash.events.EventDispatcher;
4
+
5
+ import com.lbi.animation.util.Engine;
6
+ import com.lbi.animation.util.IAnimation;
7
+ //import com.framfab.debug.Console;
8
+ [Event("complete")]
9
+ /**
10
+ LBi Useful ActionScript 3 Library
11
+ Copyright (C) 2007 LBi / Michael Forrest
12
+
13
+ This library is free software; you can redistribute it and/or
14
+ modify it under the terms of the GNU Lesser General Public
15
+ License as published by the Free Software Foundation; either
16
+ version 2.1 of the License, or (at your option) any later version.
17
+
18
+ This library is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ Lesser General Public License for more details.
22
+
23
+ You should have received a copy of the GNU Lesser General Public
24
+ License along with this library; if not, write to the Free Software
25
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+ */
27
+ public class Animation extends EventDispatcher implements IAnimation {
28
+ private var anim_function:Function;
29
+
30
+ protected var num_frames:Number;
31
+ private var current_frame:Number;
32
+ private var start:Number;
33
+ private var end:Number;
34
+ private var increment:Number;
35
+ private var isPlaying:Boolean = false;
36
+
37
+ private var label:String = "";
38
+
39
+ protected var is_complete:Boolean = true;
40
+
41
+ private var __complete_event : Event;
42
+ private var engine : Engine;
43
+
44
+ public function get complete_event():Event{
45
+ return __complete_event;
46
+ }
47
+ public function set complete_event(v:Event):void{
48
+ __complete_event = v;
49
+ }
50
+
51
+ /**
52
+ * Animation class
53
+ * Version 1.1
54
+ * Enterframe function can now take the _previous_ value as its second parameter
55
+ * Example:
56
+ * <pre>
57
+ private var my_animation:Animation;
58
+ public function startAnimation(){
59
+ my_animation = new Animation(this, myFrameAnimation, 0, 1, 15);
60
+ my_animation.addEventListener("animationComplete", myCompleteFunction);
61
+ }
62
+ private function myFrameAnimation(n:Number){
63
+ // use the appropriate easing function here
64
+ // in this example, the _alpha value of my_mc needs to go from
65
+ // 50 to 100 with easeInQuad
66
+ n = Tweens.easeInQuad(n);
67
+ my_mc._alpha = 50 + (50 * n);
68
+ }
69
+ private function myCompleteFunction(){
70
+ trace("Animation complete!!");
71
+ }
72
+ * </pre>
73
+ *
74
+ * @param instance - the instance to animate
75
+ * @param anim_function - a function that will be called each frame, with one argument (the current position in the animation)
76
+ * @param start - value to start with
77
+ * @param end - value to finish on
78
+ * @param num_frames - the number of frames in the animation
79
+ */
80
+ function Animation($anim_function:Function, start:Number, end:Number, num_frames:Number){
81
+ engine = Engine.getInstance();
82
+ this.complete_event = new Event("complete");
83
+ anim_function = $anim_function;
84
+ /** make sure it's integer, and >=1 **/
85
+ this.num_frames = Math.round(num_frames);
86
+ this.num_frames = Math.max(this.num_frames, 1);
87
+ setStart(start);
88
+ setEnd(end);
89
+
90
+ }
91
+ public function setStart(n:Number) : void {
92
+ start = n;
93
+ }
94
+ public function setEnd(n:Number) : void {
95
+ end = n;
96
+ }
97
+ public function go() : void {
98
+ is_complete =false;
99
+ increment = (end - start) / num_frames;
100
+ this.current_frame = 0;
101
+ engine.addEventListener(Event.ENTER_FRAME, doAnimation,false,0,true);
102
+ isPlaying = true;
103
+ }
104
+ public function destroy() : void {
105
+ engine.removeEventListener(Event.ENTER_FRAME, doAnimation);
106
+ delete this;
107
+ }
108
+ private function doAnimation(e:Event) : void {
109
+ var p:Number = start + (current_frame * increment);
110
+ current_frame ++;
111
+ var n:Number = start + (current_frame * increment);
112
+ anim_function(n,p);
113
+ if(current_frame == num_frames){
114
+ engine.removeEventListener(Event.ENTER_FRAME, doAnimation);
115
+ isPlaying = false;
116
+ is_complete = true;
117
+ dispatchCompleteEvent();
118
+ destroy();
119
+ }
120
+ }
121
+ public function pause() : void {
122
+ if( isPlaying){
123
+ engine.removeEventListener(Event.ENTER_FRAME, doAnimation);
124
+ }else{
125
+ engine.addEventListener(Event.ENTER_FRAME, doAnimation,false,0,true);
126
+ }
127
+ }
128
+ public function stop(dispatchComplete:Boolean = false) : void {
129
+ engine.removeEventListener(Event.ENTER_FRAME, doAnimation);
130
+ isPlaying = false;
131
+ is_complete = true;
132
+ if(dispatchComplete) dispatchCompleteEvent();
133
+ }
134
+
135
+ public function addLabel(l:String) : void {
136
+ label = l;
137
+ }
138
+ public function isComplete():Boolean{
139
+ return is_complete;
140
+ }
141
+ public function setFrames(n:Number) : void {
142
+ this.num_frames = n;
143
+ }
144
+ public function getFrames():Number{
145
+ return num_frames;
146
+ }
147
+ public function getCurrentFrame():Number{
148
+ return current_frame;
149
+ }
150
+ override public function toString() : String {
151
+ return getType() + " " + label + ", playing: "+ isPlaying;
152
+ }
153
+ public function getType():String {
154
+ return "animation " ;
155
+ }
156
+ private function dispatchCompleteEvent() : void {
157
+ dispatchEvent(complete_event);
158
+ }
159
+
160
+ public function getStructure() : String {
161
+ return toString();
162
+ }
163
+
164
+ public function setCompleteDelegate(delegate : Function) : void {
165
+
166
+ }
167
+
168
+ public function getCompleteDelegate() : Function {
169
+ return null;
170
+ }
171
+
172
+ }
173
+ }
@@ -0,0 +1,36 @@
1
+ package com.lbi.animation.single {
2
+ import com.lbi.animation.single.MethodWithCompleteEvent;
3
+ import com.lbi.debug.Log;
4
+ /**
5
+ LBi Useful ActionScript 3 Library
6
+ Copyright (C) 2007 LBi / Michael Forrest
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation; either
11
+ version 2.1 of the License, or (at your option) any later version.
12
+
13
+ This library is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General Public
19
+ License along with this library; if not, write to the Free Software
20
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ */
22
+ public class Message extends MethodWithCompleteEvent {
23
+
24
+ private var message : String;
25
+
26
+ public function Message(message:String) {
27
+ super();
28
+ this.message = message;
29
+ }
30
+ override public function go() : void {
31
+ complete = false;
32
+ Log.info(message);
33
+ onComplete(null);
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,75 @@
1
+ package com.lbi.animation.single {
2
+ import flash.events.Event;
3
+ import flash.events.EventDispatcher;
4
+ import flash.events.IEventDispatcher;
5
+
6
+ import com.lbi.animation.util.IAnimation;
7
+
8
+ [Event("complete")]
9
+ /**
10
+ LBi Useful ActionScript 3 Library
11
+ Copyright (C) 2007 LBi / Michael Forrest
12
+
13
+ This library is free software; you can redistribute it and/or
14
+ modify it under the terms of the GNU Lesser General Public
15
+ License as published by the Free Software Foundation; either
16
+ version 2.1 of the License, or (at your option) any later version.
17
+
18
+ This library is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ Lesser General Public License for more details.
22
+
23
+ You should have received a copy of the GNU Lesser General Public
24
+ License along with this library; if not, write to the Free Software
25
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+ */
27
+ public class MethodWithCompleteEvent extends EventDispatcher implements IAnimation {
28
+ private var object : IEventDispatcher;
29
+ private var method:Function;
30
+ protected var complete:Boolean = false;
31
+
32
+ private var complete_event : String;
33
+
34
+ private var __arguments : Array;
35
+
36
+ public function MethodWithCompleteEvent($object : IEventDispatcher = null, $method : Function = null, $complete_event : String = null, $args: Array = null){
37
+ complete_event = $complete_event;
38
+ object = $object;
39
+ method = $method;
40
+ __arguments = $args;
41
+ }
42
+ public function go() : void {
43
+ if(complete_event) object.addEventListener(complete_event, onComplete,false,0,true);
44
+ complete = false;
45
+ if(method != null) method.apply(object,__arguments);
46
+ if(!complete_event) onComplete(null);
47
+ }
48
+ protected function onComplete(e:Event) : void {
49
+ complete = true;
50
+ dispatchEvent(new Event("complete"));
51
+ }
52
+ public function destroy() : void {
53
+ delete this;
54
+ }
55
+
56
+ public function stop(dispatchComplete : Boolean = false) : void {
57
+ //my_object.stop();
58
+ if(dispatchComplete) onComplete(null);
59
+ }
60
+
61
+ public function isComplete():Boolean{
62
+ return complete;
63
+ }
64
+ public function setFrames(frames : Number) : void {
65
+ }
66
+ override public function toString():String{
67
+ return "QueueMethod: ";
68
+ }
69
+ public function getStructure() : String {
70
+ return toString();
71
+ }
72
+
73
+ }
74
+
75
+ }
@@ -0,0 +1,78 @@
1
+ package com.lbi.animation.single {
2
+ import com.lbi.animation.util.IAnimation;
3
+
4
+ import flash.events.Event;
5
+ import flash.events.EventDispatcher;
6
+ import flash.events.IEventDispatcher;
7
+ /**
8
+ LBi Useful ActionScript 3 Library
9
+ Copyright (C) 2007 LBi / Michael Forrest
10
+
11
+ This library is free software; you can redistribute it and/or
12
+ modify it under the terms of the GNU Lesser General Public
13
+ License as published by the Free Software Foundation; either
14
+ version 2.1 of the License, or (at your option) any later version.
15
+
16
+ This library is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
+ Lesser General Public License for more details.
20
+
21
+ You should have received a copy of the GNU Lesser General Public
22
+ License along with this library; if not, write to the Free Software
23
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
+ */
25
+ public class OrphanEvent extends EventDispatcher implements IAnimation{
26
+ public var is_complete:Boolean = false;
27
+ private var object:IEventDispatcher;
28
+ private var event:String;
29
+ private var timeCreated:Number;
30
+ public function get EventObject():IEventDispatcher{
31
+ return object;
32
+ }
33
+ public function get EventName():String{
34
+ return event;
35
+ }
36
+
37
+ public function OrphanEvent($object:IEventDispatcher, $event:String){
38
+ object = $object;
39
+ event = $event;
40
+ object.addEventListener(event, dispatchCompleteEvent,false,0,true);
41
+ }
42
+ public function stop(dispatchComplete:Boolean = false) : void {
43
+ destroy();
44
+ if(dispatchComplete) dispatchCompleteEvent();
45
+ }
46
+ private function dispatchCompleteEvent(e : Event = null) : void {
47
+ is_complete = true;
48
+ dispatchEvent(new Event("complete"));
49
+ }
50
+ /**
51
+ * go() does nothing, hence "Orphan".
52
+ */
53
+ public function go() : void {
54
+ is_complete = false;
55
+ }
56
+
57
+ public function isComplete():Boolean{
58
+ return is_complete;
59
+ }
60
+ public function destroy() : void {
61
+ object.removeEventListener(event, dispatchCompleteEvent);
62
+ }
63
+ override public function toString() : String {
64
+ return object + " OrphanEvent " + timeCreated + ":" + event ;
65
+ }
66
+ public function isOrphanEvent():Boolean{
67
+ return true;
68
+ }
69
+ public function setFrames(frames : Number) : void {
70
+ // don't do anything though.
71
+ }
72
+
73
+ public function getStructure() : String {
74
+ return toString();
75
+ }
76
+
77
+ }
78
+ }
@@ -0,0 +1,35 @@
1
+ package com.lbi.animation.single {
2
+ import com.lbi.animation.single.Animation;
3
+ /**
4
+ LBi Useful ActionScript 3 Library
5
+ Copyright (C) 2007 LBi / Michael Forrest
6
+
7
+ This library is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU Lesser General Public
9
+ License as published by the Free Software Foundation; either
10
+ version 2.1 of the License, or (at your option) any later version.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General Public
18
+ License along with this library; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ */
21
+ public class Pause extends Animation {
22
+
23
+ private var ease:Function;
24
+ /**
25
+ * Pause creates a pause for a certain number of frames. This class can be used in conjunction with Queue.
26
+ * @see com.lbi.animation.Animation
27
+ * @see com.lbi.animation.Queue
28
+ */
29
+ function Pause(frames:Number){
30
+ super(pauseCheck, 0, 1, frames);
31
+ }
32
+ private function pauseCheck(n:Number, p:Number) : void {
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,73 @@
1
+ package com.lbi.animation.single {
2
+ import flash.display.DisplayObject;
3
+
4
+ import com.lbi.animation.single.Animation;
5
+ import com.lbi.animation.util.Easing;
6
+ /**
7
+ LBi Useful ActionScript 3 Library
8
+ Copyright (C) 2007 LBi / Michael Forrest
9
+
10
+ This library is free software; you can redistribute it and/or
11
+ modify it under the terms of the GNU Lesser General Public
12
+ License as published by the Free Software Foundation; either
13
+ version 2.1 of the License, or (at your option) any later version.
14
+
15
+ This library is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ Lesser General Public License for more details.
19
+
20
+ You should have received a copy of the GNU Lesser General Public
21
+ License along with this library; if not, write to the Free Software
22
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
+ */
24
+ public class Tween extends Animation{
25
+ private var property_name:String;
26
+ private var property_start:Number;
27
+ private var property_end:Number;
28
+ private var delta:Number;
29
+ private var object:Object;
30
+ private var ease:Function;
31
+ /**
32
+ * Tween handles simple MovieClip property animations - all animations will start from the property's current value
33
+ * Example:
34
+ * <pre>
35
+ * var fade_animation:Tween = new Tween(my_mc, "_alpha", 50, 20, Easing.easeInCubic);
36
+ * fade_animation.go();
37
+ * </pre>
38
+ * @see com.lbi.animation.Animation
39
+ */
40
+ function Tween(object:DisplayObject, property_name:String, target_value:Number, frames:Number, easing:Function = null) {
41
+ super(tweenValue, 0, 1, frames);
42
+ if(easing == null) ease = Easing.linearTween;
43
+ this.object = object;
44
+ this.property_name = property_name;
45
+ property_end = target_value;
46
+
47
+ }
48
+ public function setTargetValue(v:Number) : void {
49
+ property_end = v;
50
+ }
51
+ override public function go() : void {
52
+ is_complete = false;
53
+ this.property_start = object[property_name];
54
+ this.delta = (property_end - object[property_name]);
55
+ super.go();
56
+ }
57
+ private function tweenValue(n:Number,p:Number) : void {
58
+ n = ease(n);
59
+ object[property_name] = (n * delta ) + property_start;
60
+ }
61
+
62
+ public function getTweenValues ( ) : Array
63
+ {
64
+ property_start = object[property_name];
65
+ delta = (property_end - property_start);
66
+ var res_arr:Array = [];
67
+ for(var i:Number=0; i<num_frames; i++){
68
+ res_arr.push( ease(i / (num_frames + 1)) * delta + property_start );
69
+ }
70
+ return res_arr;
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,158 @@
1
+ package com.lbi.animation.util {
2
+
3
+ // see http://hosted.zeh.com.br/mctween/animationtypes.html
4
+
5
+ public class Easing {
6
+ public static function linearTween(t:Number):Number {
7
+ return 1*t/1;
8
+ };
9
+
10
+ public static function easeInQuad(t:Number):Number {
11
+ return 1*(t/=1)*t;
12
+ };
13
+ public static function easeOutQuad(t:Number):Number {
14
+ return -1 *(t/=1)*(t-2);
15
+ };
16
+ public static function easeInOutQuad(t:Number):Number {
17
+ if ((t/=1/2) < 1) return 1/2*t*t;
18
+ return -1/2 * ((--t)*(t-2) - 1);
19
+ };
20
+ public static function easeInCubic(t:Number):Number {
21
+ return 1*(t/=1)*t*t;
22
+ };
23
+ public static function easeOutCubic(t:Number):Number {
24
+ return 1*((t=t/1-1)*t*t + 1);
25
+ };
26
+ public static function easeInOutCubic(t:Number):Number {
27
+ if ((t/=1/2) < 1) return 1/2*t*t*t;
28
+ return 1/2*((t-=2)*t*t + 2);
29
+ };
30
+ public static function easeInQuart(t:Number):Number {
31
+ return 1*(t/=1)*t*t*t;
32
+ };
33
+ public static function easeOutQuart(t:Number):Number {
34
+ return -1 * ((t=t/1-1)*t*t*t - 1);
35
+ };
36
+ public static function easeInOutQuart(t:Number):Number {
37
+ if ((t/=1/2) < 1) return 1/2*t*t*t*t;
38
+ return -1/2 * ((t-=2)*t*t*t - 2);
39
+ };
40
+ public static function easeInQuint(t:Number):Number {
41
+ return 1*(t/=1)*t*t*t*t;
42
+ };
43
+ public static function easeOutQuint(t:Number):Number {
44
+ return 1*((t=t/1-1)*t*t*t*t + 1);
45
+ };
46
+ public static function easeInOutQuint(t:Number):Number {
47
+ if ((t/=1/2) < 1) return 1/2*t*t*t*t*t;
48
+ return 1/2*((t-=2)*t*t*t*t + 2);
49
+ };
50
+ public static function easeInSine(t:Number):Number {
51
+ return -1 * Math.cos(t/1 * (Math.PI/2)) + 1;
52
+ };
53
+ public static function easeOutSine(t:Number):Number {
54
+ return 1 * Math.sin(t/1 * (Math.PI/2));
55
+ };
56
+ public static function easeInOutSine(t:Number):Number {
57
+ return -1/2 * (Math.cos(Math.PI*t/1) - 1);
58
+ };
59
+ public static function easeInExpo(t:Number):Number {
60
+ return (t==0) ? 0 : 1 * Math.pow(2, 10 * (t/1 - 1));
61
+ };
62
+ public static function easeOutExpo(t:Number):Number {
63
+ return (t==1) ? 1 : 1 * (-Math.pow(2, -10 * t/1) + 1);
64
+ };
65
+ public static function easeInOutExpo(t:Number):Number {
66
+ if (t==0) return 0;
67
+ if (t==1) return 1;
68
+ if ((t/=1/2) < 1) return 1/2 * Math.pow(2, 10 * (t - 1));
69
+ return 1/2 * (-Math.pow(2, -10 * --t) + 2);
70
+ };
71
+ public static function easeInCirc(t:Number):Number {
72
+ return -1 * (Math.sqrt(1 - (t/=1)*t) - 1);
73
+ };
74
+ public static function easeOutCirc(t:Number):Number {
75
+ return 1 * Math.sqrt(1 - (t=t/1-1)*t);
76
+ };
77
+ public static function easeInOutCirc(t:Number):Number {
78
+ if ((t/=1/2) < 1) return -1/2 * (Math.sqrt(1 - t*t) - 1);
79
+ return 1/2 * (Math.sqrt(1 - (t-=2)*t) + 1);
80
+ };
81
+ public static function easeInElastic(t:Number, a:Number = 10, p:Number= 10):Number {
82
+ var s:Number;
83
+ if (t==0) return 0; if ((t/=1)==1) return 1; if (!p) p=1*.3;
84
+ if (a < Math.abs(1)) { a=1; s=p/4; }
85
+ else s = p/(2*Math.PI) * Math.asin (1/a);
86
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p ));
87
+ };
88
+
89
+ public static function easeOutElastic(t:Number, a:Number=1, p:Number =1.05):Number {
90
+ var s:Number;
91
+ if (t==0) return 0; if ((t/=1)==1) return 1;
92
+ if (a < Math.abs(1)) { a=1; s=p/4; }
93
+ else s = p/(2*Math.PI) * Math.asin (1/a);
94
+ return a*Math.pow(2,-10*t) * Math.sin( (t*1-s)*(2*Math.PI)/p ) + 1;
95
+ };
96
+
97
+ public static function easeInOutElastic(t:Number, a:Number = 1, p:Number=1*(.3*1.5)):Number {
98
+ var s:Number;
99
+ if (t==0) return 1; if ((t/=1/2)==2) return 1;
100
+ if (a < Math.abs(1)) { a=1; s=p/4; }
101
+ else s = p/(2*Math.PI) * Math.asin (1/a);
102
+ if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p ));
103
+ return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p )*.5 + 1;
104
+ };
105
+ public static function easeInBack(t:Number, s:Number):Number {
106
+ if (isNaN(s)) s = 1.70158;
107
+ return 1*(t/=1)*t*((s+1)*t - s);
108
+ };
109
+ public static function easeOutBack(t:Number, s:Number):Number {
110
+ if (isNaN(s)) s = 1.70158;
111
+ return 1*((t=t/1-1)*t*((s+1)*t + s) + 1);
112
+ };
113
+ public static function easeInOutBack(t:Number, s:Number):Number {
114
+ if (isNaN(s)) s = 1.70158;
115
+ if ((t/=1/2) < 1) return 1/2*(t*t*(((s*=(1.525))+1)*t - s));
116
+ return 1/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2);
117
+ };
118
+ public static function easeInBounce(t:Number):Number {
119
+ return 1 - Easing.easeOutBounce (1-t);
120
+ };
121
+ public static function easeOutBounce(t:Number):Number {
122
+ if ((t/=1) < (1/2.75)) {
123
+ return 1*(7.5625*t*t);
124
+ } else if (t < (2/2.75)) {
125
+ return 1*(7.5625*(t-=(1.5/2.75))*t + .75);
126
+ } else if (t < (2.5/2.75)) {
127
+ return 1*(7.5625*(t-=(2.25/2.75))*t + .9375);
128
+ } else {
129
+ return 1*(7.5625*(t-=(2.625/2.75))*t + .984375);
130
+ }
131
+ }
132
+ public static function easeInOutBounce(t:Number):Number {
133
+ if (t < 1/2) return Easing.easeInBounce (t*2) * .5;
134
+ return Easing.easeOutBounce (t*2-1) * .5 + 1*.5;
135
+ }
136
+ public static function cubBezier(mu:Number,p2:Number,p3:Number):Number {
137
+ var mum1:Number,mum13:Number,mu3:Number,p1:Number,p4:Number;
138
+ p1 = 0;
139
+ p4 = 1;
140
+ var p:Number;
141
+ mum1 = 1 - mu;
142
+ mum13 = mum1 * mum1 * mum1;
143
+ mu3 = mu * mu * mu;
144
+ var mu4:Number = 3*mu*mum1*mum1;
145
+ var mu5:Number = 3*mu*mu*mum1;
146
+ p = mum13*p1 + mu4*p2 + mu5*p3 + mu3*p4;
147
+ return p;
148
+ }
149
+ public static function quadBezier(mu:Number,p2:Number):Number {
150
+ var p:Number;
151
+ var mum1:Number = 2*(1 - mu);
152
+ var p1:Number = 0;
153
+ var p3:Number = 1;
154
+ p = p1 + mu*(mum1*(p2-p1) + mu*(p3 - p1));
155
+ return p;
156
+ }
157
+ }
158
+ }
@@ -0,0 +1,35 @@
1
+ package com.lbi.animation.util {
2
+ import flash.events.Event;
3
+ import flash.events.EventDispatcher;
4
+ import flash.events.TimerEvent;
5
+ import flash.utils.Timer;
6
+ /**
7
+ * @author michaelforrest
8
+ */
9
+ public class Engine extends EventDispatcher {
10
+ private static var instance : Engine;
11
+ private var timer : Timer;
12
+
13
+ public function Engine() {
14
+ timer = new Timer(1000/30);
15
+ timer.addEventListener(TimerEvent.TIMER, advanceFrame,false,0,true);
16
+ timer.start();
17
+ }
18
+
19
+ public static function getInstance() : Engine {
20
+ if(!instance) instance = new Engine();
21
+ return instance;
22
+ }
23
+ public static function advanceFrames(number_of_frames : Number) : void {
24
+ if(!instance) getInstance();
25
+ for (var i : Number = 0; i < number_of_frames; i++) {
26
+ instance.advanceFrame();
27
+
28
+ }
29
+ }
30
+
31
+ private function advanceFrame(e:TimerEvent = null) : void {
32
+ dispatchEvent(new Event(Event.ENTER_FRAME));
33
+ }
34
+ }
35
+ }