@@ -202,15 +202,15 @@ var TweenBuilder = function (manager, config)
202202 var props = GetProps ( config ) ;
203203
204204 // Default Tween values
205- var easeParams = GetValue ( config , 'easeParams' , null ) ;
206- var ease = GetEaseFunction ( GetValue ( config , 'ease' , 'Power0' ) , easeParams ) ;
205+ var delay = GetNewValue ( config , 'delay' , 0 ) ;
207206 var duration = GetNewValue ( config , 'duration' , 1000 ) ;
208- var yoyo = GetBoolean ( config , 'yoyo' , false ) ;
207+ var ease = GetEaseFunction ( GetValue ( config , 'ease' , 'Power0' ) , easeParams ) ;
208+ var easeParams = GetValue ( config , 'easeParams' , null ) ;
209209 var hold = GetNewValue ( config , 'hold' , 0 ) ;
210210 var repeat = GetNewValue ( config , 'repeat' , 0 ) ;
211211 var repeatDelay = GetNewValue ( config , 'repeatDelay' , 0 ) ;
212- var delay = GetNewValue ( config , 'delay' , 0 ) ;
213212 var startAt = GetNewValue ( config , 'startAt' , null ) ;
213+ var yoyo = GetBoolean ( config , 'yoyo' , false ) ;
214214
215215 var data = [ ] ;
216216
@@ -248,11 +248,82 @@ var TweenBuilder = function (manager, config)
248248 var tween = new Tween ( manager , data ) ;
249249
250250 tween . totalTargets = targets . length ;
251- tween . useFrames = GetBoolean ( config , 'useFrames' , false ) ;
251+
252+ tween . completeDelay = GetAdvancedValue ( config , 'completeDelay' , 0 ) ;
252253 tween . loop = GetAdvancedValue ( config , 'loop' , 0 ) ;
253254 tween . loopDelay = GetAdvancedValue ( config , 'loopDelay' , 0 ) ;
254- tween . completeDelay = GetAdvancedValue ( config , 'completeDelay' , 0 ) ;
255255 tween . paused = GetBoolean ( config , 'paused' , false ) ;
256+ tween . useFrames = GetBoolean ( config , 'useFrames' , false ) ;
257+
258+ // Callbacks
259+
260+ var scope = GetValue ( config , 'callbackScope' , tween ) ;
261+
262+ var onStart = GetValue ( config , 'onStart' , false ) ;
263+
264+ // The Start of the Tween
265+ if ( onStart )
266+ {
267+ var onStartScope = GetValue ( config , 'onStartScope' , scope ) ;
268+ var onStartParams = GetValue ( config , 'onStartParams' , [ ] ) ;
269+
270+ tween . setEventCallback ( 'onStart' , onStart , [ tween ] . concat ( onStartParams ) , onStartScope ) ;
271+ }
272+
273+ var onUpdate = GetValue ( config , 'onUpdate' , false ) ;
274+
275+ // Every time the tween updates (regardless which TweenDatas are running)
276+ if ( onUpdate )
277+ {
278+ var onUpdateScope = GetValue ( config , 'onUpdateScope' , scope ) ;
279+ var onUpdateParams = GetValue ( config , 'onUpdateParams' , [ ] ) ;
280+
281+ tween . setEventCallback ( 'onUpdate' , onUpdate , [ tween ] . concat ( onUpdateParams ) , onUpdateScope ) ;
282+ }
283+
284+ var onRepeat = GetValue ( config , 'onRepeat' , false ) ;
285+
286+ // When a TweenData repeats
287+ if ( onRepeat )
288+ {
289+ var onRepeatScope = GetValue ( config , 'onRepeatScope' , scope ) ;
290+ var onRepeatParams = GetValue ( config , 'onRepeatParams' , [ ] ) ;
291+
292+ tween . setEventCallback ( 'onRepeat' , onRepeat , [ tween ] . concat ( onRepeatParams ) , onRepeatScope ) ;
293+ }
294+
295+ var onLoop = GetValue ( config , 'onLoop' , false ) ;
296+
297+ // Called when the whole Tween loops
298+ if ( onLoop )
299+ {
300+ var onLoopScope = GetValue ( config , 'onLoopScope' , scope ) ;
301+ var onLoopParams = GetValue ( config , 'onLoopParams' , [ ] ) ;
302+
303+ tween . setEventCallback ( 'onLoop' , onLoop , [ tween ] . concat ( onLoopParams ) , onLoopScope ) ;
304+ }
305+
306+ var onYoyo = GetValue ( config , 'onYoyo' , false ) ;
307+
308+ // Called when a TweenData yoyos
309+ if ( onYoyo )
310+ {
311+ var onYoyoScope = GetValue ( config , 'onYoyoScope' , scope ) ;
312+ var onYoyoParams = GetValue ( config , 'onYoyoParams' , [ ] ) ;
313+
314+ tween . setEventCallback ( 'onYoyo' , onYoyo , [ tween ] . concat ( onYoyoParams ) , onYoyoScope ) ;
315+ }
316+
317+ var onComplete = GetValue ( config , 'onComplete' , false ) ;
318+
319+ // Called when the Tween completes, after the completeDelay, etc.
320+ if ( onComplete )
321+ {
322+ var onCompleteScope = GetValue ( config , 'onCompleteScope' , scope ) ;
323+ var onCompleteParams = GetValue ( config , 'onCompleteParams' , [ ] ) ;
324+
325+ tween . setEventCallback ( 'onComplete' , onComplete , [ tween ] . concat ( onCompleteParams ) , onCompleteScope ) ;
326+ }
256327
257328 return tween ;
258329} ;
0 commit comments