msg-chumby-display 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/VERSION +1 -1
  2. data/bin/msg-chumby-daemon +6 -1
  3. data/etc/msgchumbydaemonrc +7 -4
  4. data/lib/msg-chumby-daemon/http-xml-server.rb +20 -1
  5. data/widget/currentpower/currentpower Report.txt +1 -1
  6. data/widget/currentpower/currentpower.swd +0 -0
  7. data/widget/currentpower/currentpower.swf +0 -0
  8. data/widget/last_reading/DataArray.as +116 -0
  9. data/widget/last_reading/Gluehlampe.fla +0 -0
  10. data/widget/last_reading/Gluehlampe.swf +0 -0
  11. data/widget/last_reading/Gluehlampe_frames.fla +0 -0
  12. data/widget/last_reading/Gluehlampe_frames.swf +0 -0
  13. data/widget/last_reading/Makefile +30 -0
  14. data/widget/last_reading/Makefile.orig +60 -0
  15. data/widget/last_reading/README.rdoc +50 -0
  16. data/widget/last_reading/README.rtf +57 -0
  17. data/widget/last_reading/XmlParse.as +1 -0
  18. data/widget/last_reading/caurina/transitions/AuxFunctions.as +88 -0
  19. data/widget/last_reading/caurina/transitions/Equations.as +713 -0
  20. data/widget/last_reading/caurina/transitions/PropertyInfoObj.as +86 -0
  21. data/widget/last_reading/caurina/transitions/SpecialProperty.as +48 -0
  22. data/widget/last_reading/caurina/transitions/SpecialPropertyModifier.as +39 -0
  23. data/widget/last_reading/caurina/transitions/SpecialPropertySplitter.as +46 -0
  24. data/widget/last_reading/caurina/transitions/TweenListObj.as +227 -0
  25. data/widget/last_reading/caurina/transitions/Tweener.as +1121 -0
  26. data/widget/last_reading/caurina/transitions/properties/ColorShortcuts.as +471 -0
  27. data/widget/last_reading/caurina/transitions/properties/CurveModifiers.as +104 -0
  28. data/widget/last_reading/caurina/transitions/properties/DisplayShortcuts.as +158 -0
  29. data/widget/last_reading/caurina/transitions/properties/FilterShortcuts.as +516 -0
  30. data/widget/last_reading/caurina/transitions/properties/SoundShortcuts.as +83 -0
  31. data/widget/last_reading/caurina/transitions/properties/TextShortcuts.as +151 -0
  32. data/widget/last_reading/energietacho.fla +0 -0
  33. data/widget/last_reading/energietacho.swf +0 -0
  34. metadata +30 -4
@@ -0,0 +1,1121 @@
1
+ /**
2
+ * Tweener
3
+ * Transition controller for movieclips, sounds, textfields and other objects
4
+ *
5
+ * @author Zeh Fernando, Nate Chatellier, Arthur Debert, Francis Turmel
6
+ * @version 1.33.74
7
+ */
8
+
9
+ /*
10
+ Licensed under the MIT License
11
+
12
+ Copyright (c) 2006-2008 Zeh Fernando, Nate Chatellier, Arthur Debert and Francis
13
+ Turmel
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
16
+ this software and associated documentation files (the "Software"), to deal in
17
+ the Software without restriction, including without limitation the rights to
18
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
19
+ the Software, and to permit persons to whom the Software is furnished to do so,
20
+ subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
27
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
28
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
29
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
+
32
+ http://code.google.com/p/tweener/
33
+ http://code.google.com/p/tweener/wiki/License
34
+ */
35
+
36
+ import caurina.transitions.Equations;
37
+ import caurina.transitions.AuxFunctions;
38
+ import caurina.transitions.SpecialProperty;
39
+ import caurina.transitions.SpecialPropertyModifier;
40
+ import caurina.transitions.SpecialPropertySplitter;
41
+ import caurina.transitions.TweenListObj;
42
+ import caurina.transitions.PropertyInfoObj;
43
+
44
+ class caurina.transitions.Tweener {
45
+
46
+ private static var _engineExists:Boolean = false; // Whether or not the engine is currently running
47
+ private static var _inited:Boolean = false; // Whether or not the class has been initiated
48
+ private static var _currentTime:Number; // The current time. This is generic for all tweenings for a "time grid" based update
49
+ private static var _currentTimeFrame:Number; // The current frame. Used on frame-based tweenings
50
+
51
+ private static var _tweenList:Array; // List of active tweens
52
+
53
+ private static var _timeScale:Number = 1; // Time scale (default = 1)
54
+
55
+ private static var _transitionList:Object; // List of "pre-fetched" transition functions
56
+ private static var _specialPropertyList:Object; // List of special properties
57
+ private static var _specialPropertyModifierList:Object; // List of special property modifiers
58
+ private static var _specialPropertySplitterList:Object; // List of special property splitters
59
+
60
+ public static var autoOverwrite:Boolean = true; // If true, auto overwrite on new tweens is on unless declared as false
61
+
62
+ /**
63
+ * There's no constructor.
64
+ */
65
+ public function Tweener () {
66
+ trace ("Tweener is an static class and should not be instantiated.");
67
+ }
68
+
69
+
70
+ // ==================================================================================================================================
71
+ // TWEENING CONTROL functions -------------------------------------------------------------------------------------------------------
72
+
73
+ /**
74
+ * Adds a new tweening
75
+ *
76
+ * @param (first-n param) Object Object that should be tweened: a movieclip, textfield, etc.. OR an array of objects
77
+ * @param (last param) Object Object containing the specified parameters in any order, as well as the properties that should be tweened and their values
78
+ * @param .time Number Time in seconds or frames for the tweening to take (defaults 2)
79
+ * @param .delay Number Delay time (defaults 0)
80
+ * @param .useFrames Boolean Whether to use frames instead of seconds for time control (defaults false)
81
+ * @param .transition String/Function Type of transition equation... (defaults to "easeoutexpo")
82
+ * @param .transitionParams Object * Direct property, See the TweenListObj class
83
+ * @param .onStart Function * Direct property, See the TweenListObj class
84
+ * @param .onUpdate Function * Direct property, See the TweenListObj class
85
+ * @param .onComplete Function * Direct property, See the TweenListObj class
86
+ * @param .onOverwrite Function * Direct property, See the TweenListObj class
87
+ * @param .onStartParams Array * Direct property, See the TweenListObj class
88
+ * @param .onUpdateParams Array * Direct property, See the TweenListObj class
89
+ * @param .onCompleteParams Array * Direct property, See the TweenListObj class
90
+ * @param .onOverwriteParams Array * Direct property, See the TweenListObj class
91
+ * @param .rounded Boolean * Direct property, See the TweenListObj class
92
+ * @param .skipUpdates Number * Direct property, See the TweenListObj class
93
+ * @return Boolean TRUE if the tween was successfully added, FALSE if otherwise
94
+ */
95
+ public static function addTween (p_scopes:Object, p_parameters:Object):Boolean {
96
+ if (p_scopes == undefined) return false;
97
+
98
+ var i:Number, j:Number, istr:String;
99
+
100
+ var rScopes:Array; // List of objects to tween
101
+ if (p_scopes instanceof Array) {
102
+ // The first argument is an array
103
+ rScopes = p_scopes.concat();
104
+ } else {
105
+ // The first argument(s) is(are) object(s)
106
+ rScopes = [p_scopes];
107
+ }
108
+
109
+ // make properties chain ("inheritance")
110
+ var p_obj:Object = TweenListObj.makePropertiesChain(p_parameters);
111
+
112
+ // Creates the main engine if it isn't active
113
+ if (!_inited) init();
114
+ if (!_engineExists || _root[getControllerName()] == undefined) startEngine(); // Quick fix for Flash not resetting the vars on double ctrl+enter...
115
+
116
+ // Creates a "safer", more strict tweening object
117
+ var rTime:Number = (isNaN(p_obj.time) ? 0 : p_obj.time); // Real time
118
+ var rDelay:Number = (isNaN(p_obj.delay) ? 0 : p_obj.delay); // Real delay
119
+
120
+ // Creates the property list; everything that isn't a hardcoded variable
121
+ var rProperties:Object = new Object(); // Object containing a list of PropertyInfoObj instances
122
+ var restrictedWords:Object = {overwrite:true, time:true, delay:true, useFrames:true, skipUpdates:true, transition:true, transitionParams:true, onStart:true, onUpdate:true, onComplete:true, onOverwrite:true, onError:true, rounded:true, onStartParams:true, onUpdateParams:true, onCompleteParams:true, onOverwriteParams:true, onStartScope:true, onUpdateScope:true, onCompleteScope:true, onOverwriteScope:true, onErrorScope:true};
123
+ var modifiedProperties:Object = new Object();
124
+ for (istr in p_obj) {
125
+ if (!restrictedWords[istr]) {
126
+ // It's an additional pair, so adds
127
+ if (_specialPropertySplitterList[istr] != undefined) {
128
+ // Special property splitter
129
+ var splitProperties:Array = _specialPropertySplitterList[istr].splitValues(p_obj[istr], _specialPropertySplitterList[istr].parameters);
130
+ for (i = 0; i < splitProperties.length; i++) {
131
+ if (_specialPropertySplitterList[splitProperties[i].name] != undefined) {
132
+ var splitProperties2:Array = _specialPropertySplitterList[splitProperties[i].name].splitValues(splitProperties[i].value, _specialPropertySplitterList[splitProperties[i].name].parameters);
133
+ for (j = 0; j < splitProperties2.length; j++) {
134
+ rProperties[splitProperties2[j].name] = {valueStart:undefined, valueComplete:splitProperties2[j].value, arrayIndex:splitProperties2[j].arrayIndex, isSpecialProperty:false};
135
+ }
136
+ } else {
137
+ rProperties[splitProperties[i].name] = {valueStart:undefined, valueComplete:splitProperties[i].value, arrayIndex:splitProperties[i].arrayIndex, isSpecialProperty:false};
138
+ }
139
+ }
140
+ } else if (_specialPropertyModifierList[istr] != undefined) {
141
+ // Special property modifier
142
+ var tempModifiedProperties:Array = _specialPropertyModifierList[istr].modifyValues(p_obj[istr]);
143
+ for (i = 0; i < tempModifiedProperties.length; i++) {
144
+ modifiedProperties[tempModifiedProperties[i].name] = {modifierParameters:tempModifiedProperties[i].parameters, modifierFunction:_specialPropertyModifierList[istr].getValue};
145
+ }
146
+ } else {
147
+ // Regular property or special property, just add the property normally
148
+ rProperties[istr] = {valueStart:undefined, valueComplete:p_obj[istr]};
149
+ }
150
+ }
151
+ }
152
+
153
+ // Verifies whether the properties exist or not, for warning messages
154
+ for (istr in rProperties) {
155
+ if (_specialPropertyList[istr] != undefined) {
156
+ rProperties[istr].isSpecialProperty = true;
157
+ } else {
158
+ if (rScopes[0][istr] == undefined) {
159
+ printError("The property '" + istr + "' doesn't seem to be a normal object property of " + rScopes[0].toString() + " or a registered special property.");
160
+ }
161
+ }
162
+ }
163
+
164
+ // Adds the modifiers to the list of properties
165
+ for (istr in modifiedProperties) {
166
+ if (rProperties[istr] != undefined) {
167
+ rProperties[istr].modifierParameters = modifiedProperties[istr].modifierParameters;
168
+ rProperties[istr].modifierFunction = modifiedProperties[istr].modifierFunction;
169
+ }
170
+
171
+ }
172
+
173
+ var rTransition:Function; // Real transition
174
+
175
+ if (typeof p_obj.transition == "string") {
176
+ // String parameter, transition names
177
+ var trans:String = p_obj.transition.toLowerCase();
178
+ rTransition = _transitionList[trans];
179
+ } else {
180
+ // Proper transition function
181
+ rTransition = p_obj.transition;
182
+ }
183
+ if (rTransition == undefined) rTransition = _transitionList["easeoutexpo"];
184
+
185
+ var nProperties:Object;
186
+ var nTween:TweenListObj;
187
+ var myT:Number;
188
+
189
+ for (i = 0; i < rScopes.length; i++) {
190
+ // Makes a copy of the properties
191
+ nProperties = new Object();
192
+ for (istr in rProperties) {
193
+ nProperties[istr] = new PropertyInfoObj(rProperties[istr].valueStart, rProperties[istr].valueComplete, rProperties[istr].valueComplete, rProperties[istr].arrayIndex, {}, rProperties[istr].isSpecialProperty, rProperties[istr].modifierFunction, rProperties[istr].modifierParameters);
194
+ }
195
+
196
+ if (p_obj.useFrames == true) {
197
+ nTween = new TweenListObj(
198
+ /* scope */ rScopes[i],
199
+ /* timeStart */ _currentTimeFrame + (rDelay / _timeScale),
200
+ /* timeComplete */ _currentTimeFrame + ((rDelay + rTime) / _timeScale),
201
+ /* useFrames */ true,
202
+ /* transition */ rTransition,
203
+ p_obj.transitionParams
204
+ );
205
+ } else {
206
+ nTween = new TweenListObj(
207
+ /* scope */ rScopes[i],
208
+ /* timeStart */ _currentTime + ((rDelay * 1000) / _timeScale),
209
+ /* timeComplete */ _currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale),
210
+ /* useFrames */ false,
211
+ /* transition */ rTransition,
212
+ p_obj.transitionParams
213
+ );
214
+ }
215
+
216
+ nTween.properties = nProperties;
217
+ nTween.onStart = p_obj.onStart;
218
+ nTween.onUpdate = p_obj.onUpdate;
219
+ nTween.onComplete = p_obj.onComplete;
220
+ nTween.onOverwrite = p_obj.onOverwrite;
221
+ nTween.onError = p_obj.onError;
222
+ nTween.onStartParams = p_obj.onStartParams;
223
+ nTween.onUpdateParams = p_obj.onUpdateParams;
224
+ nTween.onCompleteParams = p_obj.onCompleteParams;
225
+ nTween.onOverwriteParams = p_obj.onOverwriteParams;
226
+ nTween.onStartScope = p_obj.onStartScope;
227
+ nTween.onUpdateScope = p_obj.onUpdateScope;
228
+ nTween.onCompleteScope = p_obj.onCompleteScope;
229
+ nTween.onOverwriteScope = p_obj.onOverwriteScope;
230
+ nTween.onErrorScope = p_obj.onErrorScope;
231
+ nTween.rounded = p_obj.rounded;
232
+ nTween.skipUpdates = p_obj.skipUpdates;
233
+
234
+ // Remove other tweenings that occur at the same time
235
+ if (p_obj.overwrite == undefined ? autoOverwrite : p_obj.overwrite) removeTweensByTime(nTween.scope, nTween.properties, nTween.timeStart, nTween.timeComplete);
236
+
237
+ // And finally adds it to the list
238
+ _tweenList.push(nTween);
239
+
240
+ // Immediate update and removal if it's an immediate tween -- if not deleted, it executes at the end of this frame execution
241
+ if (rTime == 0 && rDelay == 0) {
242
+ myT = _tweenList.length-1;
243
+ updateTweenByIndex(myT);
244
+ removeTweenByIndex(myT);
245
+ }
246
+ }
247
+
248
+ return true;
249
+ }
250
+
251
+ // A "caller" is like this: [ | | | ||] got it? :)
252
+ // this function is crap - should be fixed later/extend on addTween()
253
+
254
+ /**
255
+ * Adds a new *caller* tweening
256
+ *
257
+ * @param (first-n param) Object Object that should be tweened: a movieclip, textfield, etc.. OR an array of objects
258
+ * @param (last param) Object Object containing the specified parameters in any order, as well as the properties that should be tweened and their values
259
+ * @param .time Number Time in seconds or frames for the tweening to take (defaults 2)
260
+ * @param .delay Number Delay time (defaults 0)
261
+ * @param .count Number Number of times this caller should be called
262
+ * @param .transition String/Function Type of transition equation... (defaults to "easeoutexpo")
263
+ * @param .onStart Function Event called when tween starts
264
+ * @param .onUpdate Function Event called when tween updates
265
+ * @param .onComplete Function Event called when tween ends
266
+ * @param .waitFrames Boolean Whether to wait (or not) one frame for each call
267
+ * @return Boolean TRUE if the tween was successfully added, FALSE if otherwise
268
+ */
269
+ public static function addCaller (p_scopes:Object, p_parameters:Object):Boolean {
270
+ if (p_scopes == undefined) return false;
271
+
272
+ var i:Number;
273
+
274
+ var rScopes:Array; // List of objects to tween
275
+ if (p_scopes instanceof Array) {
276
+ // The first argument is an array
277
+ rScopes = p_scopes.concat();
278
+ } else {
279
+ // The first argument(s) is(are) object(s)
280
+ rScopes = [p_scopes];
281
+ }
282
+
283
+ var p_obj:Object = p_parameters;
284
+
285
+ // Creates the main engine if it isn't active
286
+ if (!_inited) init();
287
+ if (!_engineExists || _root[getControllerName()] == undefined) startEngine(); // Quick fix for Flash not resetting the vars on double ctrl+enter...
288
+
289
+ // Creates a "safer", more strict tweening object
290
+ var rTime:Number = (isNaN(p_obj.time) ? 0 : p_obj.time); // Real time
291
+ var rDelay:Number = (isNaN(p_obj.delay) ? 0 : p_obj.delay); // Real delay
292
+
293
+ var rTransition:Function; // Real transition
294
+ if (typeof p_obj.transition == "string") {
295
+ // String parameter, transition names
296
+ var trans:String = p_obj.transition.toLowerCase();
297
+ rTransition = _transitionList[trans];
298
+ } else {
299
+ // Proper transition function
300
+ rTransition = p_obj.transition;
301
+ }
302
+ if (rTransition == undefined) rTransition = _transitionList["easeoutexpo"];
303
+
304
+ var nTween:TweenListObj;
305
+ var myT:Number;
306
+ for (i = 0; i < rScopes.length; i++) {
307
+
308
+ if (p_obj.useFrames == true) {
309
+ nTween = new TweenListObj(
310
+ /* scope */ rScopes[i],
311
+ /* timeStart */ _currentTimeFrame + (rDelay / _timeScale),
312
+ /* timeComplete */ _currentTimeFrame + ((rDelay + rTime) / _timeScale),
313
+ /* useFrames */ true,
314
+ /* transition */ rTransition,
315
+ p_obj.transitionParams
316
+ );
317
+ } else {
318
+ nTween = new TweenListObj(
319
+ /* scope */ rScopes[i],
320
+ /* timeStart */ _currentTime + ((rDelay * 1000) / _timeScale),
321
+ /* timeComplete */ _currentTime + (((rDelay * 1000) + (rTime * 1000)) / _timeScale),
322
+ /* useFrames */ false,
323
+ /* transition */ rTransition,
324
+ p_obj.transitionParams
325
+ );
326
+ }
327
+
328
+ nTween.properties = undefined;
329
+ nTween.onStart = p_obj.onStart;
330
+ nTween.onUpdate = p_obj.onUpdate;
331
+ nTween.onComplete = p_obj.onComplete;
332
+ nTween.onOverwrite = p_obj.onOverwrite;
333
+ nTween.onStartParams = p_obj.onStartParams;
334
+ nTween.onUpdateParams = p_obj.onUpdateParams;
335
+ nTween.onCompleteParams = p_obj.onCompleteParams;
336
+ nTween.onOverwriteParams = p_obj.onOverwriteParams;
337
+ nTween.onStartScope = p_obj.onStartScope;
338
+ nTween.onUpdateScope = p_obj.onUpdateScope;
339
+ nTween.onCompleteScope = p_obj.onCompleteScope;
340
+ nTween.onOverwriteScope = p_obj.onOverwriteScope;
341
+ nTween.onErrorScope = p_obj.onErrorScope;
342
+ nTween.isCaller = true;
343
+ nTween.count = p_obj.count;
344
+ nTween.waitFrames = p_obj.waitFrames;
345
+
346
+ // And finally adds it to the list
347
+ _tweenList.push(nTween);
348
+
349
+ // Immediate update and removal if it's an immediate tween -- if not deleted, it executes at the end of this frame execution
350
+ if (rTime == 0 && rDelay == 0) {
351
+ myT = _tweenList.length-1;
352
+ updateTweenByIndex(myT);
353
+ removeTweenByIndex(myT);
354
+ }
355
+ }
356
+
357
+ return true;
358
+ }
359
+
360
+ /**
361
+ * Remove an specified tweening of a specified object the tweening list, if it conflicts with the given time
362
+ *
363
+ * @param p_scope Object List of objects affected
364
+ * @param p_properties Object List of properties affected (PropertyInfoObj instances)
365
+ * @param p_timeStart Number Time when the new tween starts
366
+ * @param p_timeComplete Number Time when the new tween ends
367
+ * @return Boolean Whether or not it actually deleted something
368
+ */
369
+ public static function removeTweensByTime (p_scope:Object, p_properties:Object, p_timeStart:Number, p_timeComplete:Number):Boolean {
370
+ var removed:Boolean = false;
371
+ var removedLocally:Boolean;
372
+
373
+ var i:Number;
374
+ var tl:Number = _tweenList.length;
375
+ var pName:String;
376
+
377
+ for (i = 0; i < tl; i++) {
378
+ if (p_scope == _tweenList[i].scope) {
379
+ // Same object...
380
+ if (p_timeComplete > _tweenList[i].timeStart && p_timeStart < _tweenList[i].timeComplete) {
381
+ // New time should override the old one...
382
+ removedLocally = false;
383
+ for (pName in _tweenList[i].properties) {
384
+ if (p_properties[pName] != undefined) {
385
+ // Same object, same property
386
+ // Finally, remove this old tweening and use the new one
387
+ if (_tweenList[i].onOverwrite != undefined) {
388
+ var eventScope:Object = _tweenList[i].onOverwriteScope != undefined ? _tweenList[i].onOverwriteScope : _tweenList[i].scope;
389
+ try {
390
+ _tweenList[i].onOverwrite.apply(eventScope, _tweenList[i].onOverwriteParams);
391
+ } catch(e:Error) {
392
+ handleError(_tweenList[i], e, "onOverwrite");
393
+ }
394
+ }
395
+ _tweenList[i].properties[pName] = undefined;
396
+ delete _tweenList[i].properties[pName];
397
+ removedLocally = true;
398
+ removed = true;
399
+ }
400
+ }
401
+ if (removedLocally) {
402
+ // Verify if this can be deleted
403
+ if (AuxFunctions.getObjectLength(_tweenList[i].properties) == 0) removeTweenByIndex(i);
404
+ }
405
+ }
406
+ }
407
+ }
408
+
409
+ return removed;
410
+ }
411
+
412
+ /**
413
+ * Remove tweenings from a given object from the tweening list
414
+ *
415
+ * @param p_tween Object Object that must have its tweens removed
416
+ * @param (2nd-last params) Object Property(ies) that must be removed
417
+ * @return Boolean Whether or not it successfully removed this tweening
418
+ */
419
+ public static function removeTweens (p_scope:Object):Boolean {
420
+ // Create the property list
421
+ var properties:Array = new Array();
422
+ var i:Number;
423
+ for (i = 1; i < arguments.length; i++) {
424
+ if (typeof(arguments[i]) == "string" && !AuxFunctions.isInArray(arguments[i], properties)) {
425
+ if (_specialPropertySplitterList[arguments[i]]){
426
+ //special property, get splitter array first
427
+ var sps:SpecialPropertySplitter = _specialPropertySplitterList[arguments[i]];
428
+ var specialProps:Array = sps.splitValues(p_scope, null);
429
+ for (var j:Number = 0; j<specialProps.length; j++){
430
+ //trace(specialProps[j].name);
431
+ properties.push(specialProps[j].name);
432
+ }
433
+ } else {
434
+ properties.push(arguments[i]);
435
+ }
436
+ }
437
+ }
438
+
439
+ // Call the affect function on the specified properties
440
+ return affectTweens(removeTweenByIndex, p_scope, properties);
441
+ }
442
+
443
+ /**
444
+ * Remove all tweenings from the engine
445
+ *
446
+ * @return Boolean Whether or not it successfully removed a tweening
447
+ */
448
+ public static function removeAllTweens ():Boolean {
449
+ var removed:Boolean = false;
450
+ var i:Number;
451
+ for (i = 0; i < _tweenList.length; i++) {
452
+ removeTweenByIndex(i);
453
+ removed = true;
454
+ }
455
+ return removed;
456
+ }
457
+
458
+ /**
459
+ * Pause tweenings from a given object
460
+ *
461
+ * @param p_scope Object Object that must have its tweens paused
462
+ * @param (2nd-last params) Object Property(ies) that must be paused
463
+ * @return Boolean Whether or not it successfully paused something
464
+ */
465
+ public static function pauseTweens (p_scope:Object):Boolean {
466
+ // Create the property list
467
+ var properties:Array = new Array();
468
+ var i:Number;
469
+ for (i = 1; i < arguments.length; i++) {
470
+ if (typeof(arguments[i]) == "string" && !AuxFunctions.isInArray(arguments[i], properties)) properties.push(arguments[i]);
471
+ }
472
+ // Call the affect function on the specified properties
473
+ return affectTweens(pauseTweenByIndex, p_scope, properties);
474
+ }
475
+
476
+ /**
477
+ * Pause all tweenings on the engine
478
+ *
479
+ * @return Boolean Whether or not it successfully paused a tweening
480
+ */
481
+ public static function pauseAllTweens ():Boolean {
482
+ var paused:Boolean = false;
483
+ var i:Number;
484
+ for (i = 0; i < _tweenList.length; i++) {
485
+ pauseTweenByIndex(i);
486
+ paused = true;
487
+ }
488
+ return paused;
489
+ }
490
+
491
+ /**
492
+ * Resume tweenings from a given object
493
+ *
494
+ * @param p_scope Object Object that must have its tweens resumed
495
+ * @param (2nd-last params) Object Property(ies) that must be resumed
496
+ * @return Boolean Whether or not it successfully resumed something
497
+ */
498
+ public static function resumeTweens (p_scope:Object):Boolean {
499
+ // Create the property list
500
+ var properties:Array = new Array();
501
+ var i:Number;
502
+ for (i = 1; i < arguments.length; i++) {
503
+ if (typeof(arguments[i]) == "string" && !AuxFunctions.isInArray(arguments[i], properties)) properties.push(arguments[i]);
504
+ }
505
+ // Call the affect function on the specified properties
506
+ return affectTweens(resumeTweenByIndex, p_scope, properties);
507
+ }
508
+
509
+ /**
510
+ * Resume all tweenings on the engine
511
+ *
512
+ * @return Boolean Whether or not it successfully resumed a tweening
513
+ */
514
+ public static function resumeAllTweens ():Boolean {
515
+ var resumed:Boolean = false;
516
+ var i:Number;
517
+ for (i = 0; i < _tweenList.length; i++) {
518
+ resumeTweenByIndex(i);
519
+ resumed = true;
520
+ }
521
+ return resumed;
522
+ }
523
+
524
+ /**
525
+ * Do some generic action on specific tweenings (pause, resume, remove, more?)
526
+ *
527
+ * @param p_function Function Function to run on the tweenings that match
528
+ * @param p_scope Object Object that must have its tweens affected by the function
529
+ * @param p_properties Array Array of strings that must be affected
530
+ * @return Boolean Whether or not it successfully affected something
531
+ */
532
+ private static function affectTweens (p_affectFunction:Function, p_scope:Object, p_properties:Array):Boolean {
533
+ var affected:Boolean = false;
534
+ var i:Number;
535
+
536
+ if (!_tweenList) return false;
537
+
538
+ for (i = 0; i < _tweenList.length; i++) {
539
+ if (_tweenList[i].scope == p_scope) {
540
+ if (p_properties.length == 0) {
541
+ // Can affect everything
542
+ p_affectFunction(i);
543
+ affected = true;
544
+ } else {
545
+ // Must check whether this tween must have specific properties affected
546
+ var affectedProperties:Array = new Array();
547
+ var j:Number;
548
+ for (j = 0; j < p_properties.length; j++) {
549
+ if (_tweenList[i].properties[p_properties[j]] != undefined) {
550
+ affectedProperties.push(p_properties[j]);
551
+ }
552
+ }
553
+ if (affectedProperties.length > 0) {
554
+ // This tween has some properties that need to be affected
555
+ var objectProperties:Number = AuxFunctions.getObjectLength(_tweenList[i].properties);
556
+ if (objectProperties == affectedProperties.length) {
557
+ // The list of properties is the same as all properties, so affect it all
558
+ p_affectFunction(i);
559
+ affected = true;
560
+ } else {
561
+ // The properties are mixed, so split the tween and affect only certain specific properties
562
+ var slicedTweenIndex:Number = splitTweens(i, affectedProperties);
563
+ p_affectFunction(slicedTweenIndex);
564
+ affected = true;
565
+ }
566
+ }
567
+ }
568
+ }
569
+ }
570
+ return affected;
571
+ }
572
+
573
+ /**
574
+ * Splits a tweening in two
575
+ *
576
+ * @param p_tween Number Object that must have its tweens split
577
+ * @param p_properties Array Array of strings containing the list of properties that must be separated
578
+ * @return Number The index number of the new tween
579
+ */
580
+ public static function splitTweens (p_tween:Number, p_properties:Array):Number {
581
+ // First, duplicates
582
+ var originalTween:TweenListObj = _tweenList[p_tween];
583
+ var newTween:TweenListObj = originalTween.clone(false);
584
+
585
+ // Now, removes tweenings where needed
586
+ var i:Number;
587
+ var pName:String;
588
+
589
+ // Removes the specified properties from the old one
590
+ for (i = 0; i < p_properties.length; i++) {
591
+ pName = p_properties[i];
592
+ if (originalTween.properties[pName] != undefined) {
593
+ originalTween.properties[pName] = undefined;
594
+ delete originalTween.properties[pName];
595
+ }
596
+ }
597
+
598
+ // Removes the unspecified properties from the new one
599
+ var found:Boolean;
600
+ for (pName in newTween.properties) {
601
+ found = false;
602
+ for (i = 0; i < p_properties.length; i++) {
603
+ if (p_properties[i] == pName) {
604
+ found = true;
605
+ break;
606
+ }
607
+ }
608
+ if (!found) {
609
+ newTween.properties[pName] = undefined;
610
+ delete newTween.properties[pName];
611
+ }
612
+ }
613
+
614
+ // If there are empty property lists, a cleanup is done on the next updateTweens() cycle
615
+ _tweenList.push(newTween);
616
+ return (_tweenList.length - 1);
617
+
618
+ }
619
+
620
+
621
+ // ==================================================================================================================================
622
+ // ENGINE functions -----------------------------------------------------------------------------------------------------------------
623
+
624
+ /**
625
+ * Updates all existing tweenings
626
+ *
627
+ * @return Boolean FALSE if no update was made because there's no tweening (even delayed ones)
628
+ */
629
+ private static function updateTweens ():Boolean {
630
+ if (_tweenList.length == 0) return false;
631
+ var i:Number;
632
+ for (i = 0; i < _tweenList.length; i++) {
633
+ // Looping throught each Tweening and updating the values accordingly
634
+ if (!_tweenList[i].isPaused) {
635
+ if (!updateTweenByIndex(i)) removeTweenByIndex(i);
636
+ if (_tweenList[i] == null) {
637
+ removeTweenByIndex(i, true);
638
+ i--;
639
+ }
640
+ }
641
+ }
642
+
643
+ return true;
644
+ }
645
+
646
+ /**
647
+ * Remove an specific tweening from the tweening list
648
+ *
649
+ * @param p_tween Number Index of the tween to be removed on the tweenings list
650
+ * @return Boolean Whether or not it successfully removed this tweening
651
+ */
652
+ public static function removeTweenByIndex (p_tween:Number, p_finalRemoval:Boolean):Boolean {
653
+ _tweenList[p_tween] = null;
654
+ if (p_finalRemoval) _tweenList.splice(p_tween, 1);
655
+ return true;
656
+ }
657
+
658
+ /**
659
+ * Pauses an specific tween
660
+ *
661
+ * @param p_tween Number Index of the tween to be paused
662
+ * @return Boolean Whether or not it successfully paused this tweening
663
+ */
664
+ public static function pauseTweenByIndex (p_tween:Number):Boolean {
665
+ var tTweening:Object = _tweenList[p_tween]; // Shortcut to this tweening
666
+ if (tTweening == null || tTweening.isPaused) return false;
667
+ tTweening.timePaused = getCurrentTweeningTime(tTweening);
668
+ tTweening.isPaused = true;
669
+
670
+ return true;
671
+ }
672
+
673
+ /**
674
+ * Resumes an specific tween
675
+ *
676
+ * @param p_tween Number Index of the tween to be resumed
677
+ * @return Boolean Whether or not it successfully resumed this tweening
678
+ */
679
+ public static function resumeTweenByIndex (p_tween:Number):Boolean {
680
+ var tTweening:Object = _tweenList[p_tween]; // Shortcut to this tweening
681
+ if (tTweening == null || !tTweening.isPaused) return false;
682
+ var cTime:Number = getCurrentTweeningTime(tTweening);
683
+ tTweening.timeStart += cTime - tTweening.timePaused;
684
+ tTweening.timeComplete += cTime - tTweening.timePaused;
685
+ tTweening.timePaused = undefined;
686
+ tTweening.isPaused = false;
687
+
688
+ return true;
689
+ }
690
+
691
+ /**
692
+ * Updates an specific tween
693
+ *
694
+ * @param i Number Index (from the tween list) of the tween that should be updated
695
+ * @return Boolean FALSE if it's already finished and should be deleted, TRUE if otherwise
696
+ */
697
+ private static function updateTweenByIndex (i:Number):Boolean {
698
+
699
+ var tTweening:Object = _tweenList[i]; // Shortcut to this tweening
700
+
701
+ if (tTweening == null || !tTweening.scope) return false;
702
+
703
+ var isOver:Boolean = false; // Whether or not it's over the update time
704
+ var mustUpdate:Boolean; // Whether or not it should be updated (skipped if false)
705
+
706
+ var nv:Number; // New value for each property
707
+
708
+ var t:Number; // current time (frames, seconds)
709
+ var b:Number; // beginning value
710
+ var c:Number; // change in value
711
+ var d:Number; // duration (frames, seconds)
712
+
713
+ var pName:String; // Property name, used in loops
714
+ var eventScope:Object; // Event scope, used to call functions
715
+
716
+ // Shortcut stuff for speed
717
+ var tScope:Object; // Current scope
718
+ var cTime:Number = getCurrentTweeningTime(tTweening);
719
+ var tProperty:Object; // Property being checked
720
+
721
+ if (cTime >= tTweening.timeStart) {
722
+ // Can already start
723
+
724
+ tScope = tTweening.scope;
725
+
726
+ if (tTweening.isCaller) {
727
+ // It's a 'caller' tween
728
+ do {
729
+ t = ((tTweening.timeComplete - tTweening.timeStart)/tTweening.count) * (tTweening.timesCalled+1);
730
+ b = tTweening.timeStart;
731
+ c = tTweening.timeComplete - tTweening.timeStart;
732
+ d = tTweening.timeComplete - tTweening.timeStart;
733
+ nv = tTweening.transition(t, b, c, d, tTweening.transitionParams);
734
+
735
+ if (cTime >= nv) {
736
+ if (tTweening.onUpdate != undefined) {
737
+ eventScope = tTweening.onUpdateScope != undefined ? tTweening.onUpdateScope : tScope;
738
+ try {
739
+ tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
740
+ } catch(e:Error) {
741
+ handleError(tTweening, e, "onUpdate");
742
+ }
743
+ }
744
+
745
+ tTweening.timesCalled++;
746
+ if (tTweening.timesCalled >= tTweening.count) {
747
+ isOver = true;
748
+ break;
749
+ }
750
+ if (tTweening.waitFrames) break;
751
+ }
752
+
753
+ } while (cTime >= nv);
754
+ } else {
755
+ // It's a normal transition tween
756
+
757
+ mustUpdate = tTweening.skipUpdates < 1 || tTweening.skipUpdates == undefined || tTweening.updatesSkipped >= tTweening.skipUpdates;
758
+
759
+ if (cTime >= tTweening.timeComplete) {
760
+ isOver = true;
761
+ mustUpdate = true;
762
+ }
763
+
764
+ if (!tTweening.hasStarted) {
765
+ // First update, read all default values (for proper filter tweening)
766
+ if (tTweening.onStart != undefined) {
767
+ eventScope = tTweening.onStartScope != undefined ? tTweening.onStartScope : tScope;
768
+ try {
769
+ tTweening.onStart.apply(eventScope, tTweening.onStartParams);
770
+ } catch(e:Error) {
771
+ handleError(tTweening, e, "onStart");
772
+ }
773
+ }
774
+ var pv:Number;
775
+ for (pName in tTweening.properties) {
776
+ if (tTweening.properties[pName].isSpecialProperty) {
777
+ // It's a special property, tunnel via the special property function
778
+ if (_specialPropertyList[pName].preProcess != undefined) {
779
+ tTweening.properties[pName].valueComplete = _specialPropertyList[pName].preProcess(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].originalValueComplete, tTweening.properties[pName].extra);
780
+ }
781
+ pv = _specialPropertyList[pName].getValue(tScope, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
782
+ } else {
783
+ // Directly read property
784
+ pv = tScope[pName];
785
+ }
786
+ tTweening.properties[pName].valueStart = isNaN(pv) ? tTweening.properties[pName].valueComplete : pv;
787
+ }
788
+ mustUpdate = true;
789
+ tTweening.hasStarted = true;
790
+ }
791
+
792
+ if (mustUpdate) {
793
+ for (pName in tTweening.properties) {
794
+ tProperty = tTweening.properties[pName];
795
+
796
+ if (isOver) {
797
+ // Tweening time has finished, just set it to the final value
798
+ nv = tProperty.valueComplete;
799
+ } else {
800
+ if (tProperty.hasModifier) {
801
+ // Modified
802
+ t = cTime - tTweening.timeStart;
803
+ d = tTweening.timeComplete - tTweening.timeStart;
804
+ nv = tTweening.transition(t, 0, 1, d, tTweening.transitionParams);
805
+ nv = tProperty.modifierFunction(tProperty.valueStart, tProperty.valueComplete, nv, tProperty.modifierParameters);
806
+ } else {
807
+ // Normal update
808
+ t = cTime - tTweening.timeStart;
809
+ b = tProperty.valueStart;
810
+ c = tProperty.valueComplete - tProperty.valueStart;
811
+ d = tTweening.timeComplete - tTweening.timeStart;
812
+ nv = tTweening.transition(t, b, c, d, tTweening.transitionParams);
813
+ }
814
+ }
815
+
816
+ if (tTweening.rounded) nv = Math.round(nv);
817
+ if (tProperty.isSpecialProperty) {
818
+ // It's a special property, tunnel via the special property method
819
+ _specialPropertyList[pName].setValue(tScope, nv, _specialPropertyList[pName].parameters, tTweening.properties[pName].extra);
820
+ } else {
821
+ // Directly set property
822
+ tScope[pName] = nv;
823
+ }
824
+ }
825
+
826
+ tTweening.updatesSkipped = 0;
827
+
828
+ if (tTweening.onUpdate != undefined) {
829
+ eventScope = tTweening.onUpdateScope != undefined ? tTweening.onUpdateScope : tScope;
830
+ try {
831
+ tTweening.onUpdate.apply(eventScope, tTweening.onUpdateParams);
832
+ } catch(e:Error) {
833
+ handleError(tTweening, e, "onUpdate");
834
+ }
835
+ }
836
+ } else {
837
+ tTweening.updatesSkipped++;
838
+ }
839
+ }
840
+
841
+ if (isOver && tTweening.onComplete != undefined) {
842
+ eventScope = tTweening.onCompleteScope != undefined ? tTweening.onCompleteScope : tScope;
843
+ try {
844
+ tTweening.onComplete.apply(eventScope, tTweening.onCompleteParams);
845
+ } catch(e:Error) {
846
+ handleError(tTweening, e, "onComplete");
847
+ }
848
+ }
849
+
850
+ return (!isOver);
851
+ }
852
+
853
+ // On delay, hasn't started, so return true
854
+ return (true);
855
+
856
+ }
857
+
858
+ /**
859
+ * Initiates the Tweener. Should only be ran once
860
+ */
861
+ private static function init():Void {
862
+ _inited = true;
863
+
864
+ // Registers all default equations
865
+ _transitionList = new Object();
866
+ Equations.init();
867
+
868
+ // Registers all default special properties
869
+ _specialPropertyList = new Object();
870
+ _specialPropertyModifierList = new Object();
871
+ _specialPropertySplitterList = new Object();
872
+ }
873
+
874
+ /**
875
+ * Adds a new function to the available transition list "shortcuts"
876
+ *
877
+ * @param p_name String Shorthand transition name
878
+ * @param p_function Function The proper equation function
879
+ */
880
+ public static function registerTransition(p_name:String, p_function:Function): Void {
881
+ if (!_inited) init();
882
+ _transitionList[p_name] = p_function;
883
+ }
884
+
885
+ /**
886
+ * Adds a new special property to the available special property list.
887
+ *
888
+ * @param p_name Name of the "special" property.
889
+ * @param p_getFunction Function that gets the value.
890
+ * @param p_setFunction Function that sets the value.
891
+ */
892
+ public static function registerSpecialProperty(p_name:String, p_getFunction:Function, p_setFunction:Function, p_parameters:Array, p_preProcessFunction:Function): Void {
893
+ if (!_inited) init();
894
+ var sp:SpecialProperty = new SpecialProperty(p_getFunction, p_setFunction, p_parameters, p_preProcessFunction);
895
+ _specialPropertyList[p_name] = sp;
896
+ }
897
+
898
+ /**
899
+ * Adds a new special property modifier to the available modifier list.
900
+ *
901
+ * @param p_name Name of the "special" property modifier.
902
+ * @param p_modifyFunction Function that modifies the value.
903
+ * @param p_getFunction Function that gets the value.
904
+ */
905
+ public static function registerSpecialPropertyModifier(p_name:String, p_modifyFunction:Function, p_getFunction:Function): Void {
906
+ if (!_inited) init();
907
+ var spm:SpecialPropertyModifier = new SpecialPropertyModifier(p_modifyFunction, p_getFunction);
908
+ _specialPropertyModifierList[p_name] = spm;
909
+ }
910
+
911
+ /**
912
+ * Adds a new special property splitter to the available splitter list.
913
+ *
914
+ * @param p_name Name of the "special" property splitter.
915
+ * @param p_splitFunction Function that splits the value.
916
+ */
917
+ public static function registerSpecialPropertySplitter(p_name:String, p_splitFunction:Function, p_parameters:Array): Void {
918
+ if (!_inited) init();
919
+ var sps:SpecialPropertySplitter = new SpecialPropertySplitter(p_splitFunction, p_parameters);
920
+ _specialPropertySplitterList[p_name] = sps;
921
+ }
922
+
923
+ /**
924
+ * Starts the Tweener class engine. It is supposed to be running every time a tween exists
925
+ */
926
+ private static function startEngine():Void {
927
+ _engineExists = true;
928
+ _tweenList = new Array();
929
+
930
+ var randomDepth:Number = Math.floor(Math.random() * 999999);
931
+ var fmc:MovieClip = _root.createEmptyMovieClip(getControllerName(), 31338+randomDepth);
932
+ fmc.onEnterFrame = function(): Void {
933
+ Tweener.onEnterFrame();
934
+ };
935
+
936
+ _currentTimeFrame = 0;
937
+ updateTime();
938
+ }
939
+
940
+ /**
941
+ * Stops the Tweener class engine
942
+ */
943
+ private static function stopEngine():Void {
944
+ _engineExists = false;
945
+ _tweenList = null;
946
+ _currentTime = 0;
947
+ _currentTimeFrame = 0;
948
+ delete _root[getControllerName()].onEnterFrame;
949
+ _root[getControllerName()].removeMovieClip();
950
+ }
951
+
952
+ /**
953
+ * Updates the time to enforce time grid-based updates
954
+ */
955
+ public static function updateTime():Void {
956
+ _currentTime = getTimer();
957
+ }
958
+
959
+ /**
960
+ * Updates the current frame count
961
+ */
962
+ public static function updateFrame():Void {
963
+ _currentTimeFrame++;
964
+ }
965
+
966
+ /**
967
+ * Ran once every frame. It's the main engine, updates all existing tweenings.
968
+ */
969
+ public static function onEnterFrame():Void {
970
+ updateTime();
971
+ updateFrame();
972
+ var hasUpdated:Boolean = false;
973
+ hasUpdated = updateTweens();
974
+ if (!hasUpdated) stopEngine(); // There's no tweening to update or wait, so it's better to stop the engine
975
+ }
976
+
977
+ /**
978
+ * Sets the new time scale.
979
+ *
980
+ * @param p_time Number New time scale (0.5 = slow, 1 = normal, 2 = 2x fast forward, etc)
981
+ */
982
+ public static function setTimeScale(p_time:Number):Void {
983
+ var i:Number;
984
+ var cTime:Number;
985
+
986
+ if (isNaN(p_time)) p_time = 1;
987
+ if (p_time < 0.00001) p_time = 0.00001;
988
+ if (p_time != _timeScale) {
989
+ // Multiplies all existing tween times accordingly
990
+ for (i = 0; i<_tweenList.length; i++) {
991
+ cTime = getCurrentTweeningTime(_tweenList[i]);
992
+ _tweenList[i].timeStart = cTime - ((cTime - _tweenList[i].timeStart) * _timeScale / p_time);
993
+ _tweenList[i].timeComplete = cTime - ((cTime - _tweenList[i].timeComplete) * _timeScale / p_time);
994
+ if (_tweenList[i].timePaused != undefined) _tweenList[i].timePaused = cTime - ((cTime - _tweenList[i].timePaused) * _timeScale / p_time);
995
+ }
996
+ // Sets the new timescale value (for new tweenings)
997
+ _timeScale = p_time;
998
+ }
999
+ }
1000
+
1001
+ // ==================================================================================================================================
1002
+ // AUXILIARY functions --------------------------------------------------------------------------------------------------------------
1003
+
1004
+ /**
1005
+ * Finds whether or not an object has any tweening
1006
+ *
1007
+ * @param p_scope Object Target object
1008
+ * @return Boolean Whether or not there's a tweening occuring on this object (paused, delayed, or active)
1009
+ */
1010
+ public static function isTweening(p_scope:Object):Boolean {
1011
+ var i:Number;
1012
+
1013
+ for (i = 0; i<_tweenList.length; i++) {
1014
+ if (_tweenList[i].scope == p_scope) {
1015
+ return true;
1016
+ }
1017
+ }
1018
+ return false;
1019
+ }
1020
+
1021
+ /**
1022
+ * Return an array containing a list of the properties being tweened for this object
1023
+ *
1024
+ * @param p_scope Object Target object
1025
+ * @return Array List of strings with properties being tweened (including delayed or paused)
1026
+ */
1027
+ public static function getTweens(p_scope:Object):Array {
1028
+ var i:Number;
1029
+ var pName:String;
1030
+ var tList:Array = new Array();
1031
+
1032
+ for (i = 0; i<_tweenList.length; i++) {
1033
+ if (_tweenList[i].scope == p_scope) {
1034
+ for (pName in _tweenList[i].properties) tList.push(pName);
1035
+ }
1036
+ }
1037
+ return tList;
1038
+ }
1039
+
1040
+ /**
1041
+ * Return the number of properties being tweened for this object
1042
+ *
1043
+ * @param p_scope Object Target object
1044
+ * @return Number Total count of properties being tweened (including delayed or paused)
1045
+ */
1046
+ public static function getTweenCount(p_scope:Object):Number {
1047
+ var i:Number;
1048
+ var c:Number = 0;
1049
+
1050
+ for (i = 0; i<_tweenList.length; i++) {
1051
+ if (_tweenList[i].scope == p_scope) {
1052
+ c += AuxFunctions.getObjectLength(_tweenList[i].properties);
1053
+ }
1054
+ }
1055
+ return c;
1056
+ }
1057
+
1058
+ /* Handles errors when Tweener executes any callbacks (onStart, onUpdate, etc)
1059
+ * If the TweenListObj specifies an <code>onError</code> callback it well get called, passing the <code>Error</code> object and the current scope as parameters. If no <code>onError</code> callback is specified, it will trace a stackTrace.
1060
+ */
1061
+ private static function handleError(pTweening : Object, pError : Error, pCallBackName : String) : Void{
1062
+ // do we have an error handler?
1063
+ if (pTweening.onError != undefined && typeof(pTweening.onError == "function")){
1064
+ // yup, there's a handler. Wrap this in a try catch in case the onError throws an error itself.
1065
+ var eventScope:Object = pTweening.onErrorScope != undefined ? pTweening.onErrorScope : pTweening.scope;
1066
+ try {
1067
+ pTweening.onError.apply(eventScope, [pTweening.scope, pError]);
1068
+ } catch (metaError : Error){
1069
+ printError(pTweening.scope.toString() + " raised an error while executing the 'onError' handler. Original error:\n " + pError + "\nonError error: " + metaError);
1070
+ }
1071
+ } else {
1072
+ // if handler is undefied or null trace the error message (allows empty onErro's to ignore errors)
1073
+ if (pTweening.onError == undefined){
1074
+ printError(pTweening.scope.toString() + " raised an error while executing the '" + pCallBackName.toString() + "'handler. \n" + pError );
1075
+ }
1076
+ }
1077
+ }
1078
+
1079
+ /**
1080
+ * Get the current tweening time (no matter if it uses frames or time as basis), given a specific tweening
1081
+ *
1082
+ * @param p_tweening TweenListObj Tween information
1083
+ */
1084
+ public static function getCurrentTweeningTime(p_tweening:Object):Number {
1085
+ return p_tweening.useFrames ? _currentTimeFrame : _currentTime;
1086
+ }
1087
+
1088
+ /**
1089
+ * Return the current tweener version
1090
+ *
1091
+ * @return String The number of the current Tweener version
1092
+ */
1093
+ public static function getVersion():String {
1094
+ return "AS2 1.33.74";
1095
+ }
1096
+
1097
+ /**
1098
+ * Return the name for the controller movieclip
1099
+ *
1100
+ * @return String The number of the current Tweener version
1101
+ */
1102
+ public static function getControllerName():String {
1103
+ return "__tweener_controller__"+Tweener.getVersion();
1104
+ }
1105
+
1106
+
1107
+
1108
+ // ==================================================================================================================================
1109
+ // DEBUG functions ------------------------------------------------------------------------------------------------------------------
1110
+
1111
+ /**
1112
+ * Output an error message
1113
+ *
1114
+ * @param p_message String The error message to output
1115
+ */
1116
+ public static function printError(p_message:String): Void {
1117
+ //
1118
+ trace("## [Tweener] Error: "+p_message);
1119
+ }
1120
+
1121
+ }