-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTweener.as
More file actions
121 lines (108 loc) · 2.29 KB
/
Copy pathTweener.as
File metadata and controls
121 lines (108 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package net.flashpunk
{
/**
* Updateable Tween container.
*/
public class Tweener
{
/**
* Persistent Tween type, will stop when it finishes.
*/
public const PERSIST:uint = 0;
/**
* Looping Tween type, will restart immediately when it finishes.
*/
public const LOOPING:uint = 1;
/**
* Oneshot Tween type, will stop and remove itself from its core container when it finishes.
*/
public const ONESHOT:uint = 2;
/**
* If the Tweener should update.
*/
public var active:Boolean = true;
/**
* If the Tweener should clear on removal. For Entities, this is when they are
* removed from a World, and for World this is when the active World is switched.
*/
public var autoClear:Boolean = false;
/**
* Constructor.
*/
public function Tweener()
{
}
/**
* Updates the Tween container.
*/
public function update():void
{
}
/**
* Adds a new Tween.
* @param t The Tween to add.
* @param start If the Tween should call start() immediately.
* @return The added Tween.
*/
public function addTween(t:Tween, start:Boolean = false):Tween
{
if (t._parent) throw new Error("Cannot add a Tween object more than once.");
t._parent = this;
t._next = _tween;
if (_tween) _tween._prev = t;
_tween = t;
if (start) _tween.start();
return t;
}
/**
* Removes a Tween.
* @param t The Tween to remove.
* @return The removed Tween.
*/
public function removeTween(t:Tween):Tween
{
if (t._parent != this) throw new Error("Core object does not contain Tween.");
if (t._next) t._next._prev = t._prev;
if (t._prev) t._prev._next = t._next;
else _tween = t._next;
t._next = t._prev = null;
t._parent = null;
t.active = false;
return t;
}
/**
* Removes all Tweens.
*/
public function clearTweens():void
{
var t:Tween = _tween,
n:Tween;
while (t)
{
n = t._next;
removeTween(t);
t = n;
}
}
/**
* Updates all contained tweens.
*/
public function updateTweens():void
{
var t:Tween = _tween,
n:Tween;
while (t)
{
n = t._next;
if (t.active)
{
t.update();
if (t._finish) t.finish();
}
t = n;
}
}
// List information.
/** @private */ internal var _tween:Tween;
}
}