From abe855b88311aa0df6291aeac830a44f789835e9 Mon Sep 17 00:00:00 2001 From: Jack Doyle Date: Fri, 1 Mar 2013 01:41:19 -0600 Subject: [PATCH] GSAP 12.0.3 and LoaderMax 1.934 - fromTo() and staggerFromTo() now have immediateRender:true as the default (previously it was false) - Fixed issue in XMLLoader that prevented it from recognizing "auditSize" in XML nodes - Added "omitLoaderMaxes" parameter to getChildrenByStatus() method in LoaderMax - Fixed issue that could cause a nested child loader not to have its "fail" event bubble up through the parent LoaderMax(es). --- src/com/greensock/TimelineLite.as | 82 ++++++++++++------------ src/com/greensock/TimelineMax.as | 14 ++-- src/com/greensock/TweenLite.as | 16 +++-- src/com/greensock/TweenMax.as | 17 +++-- src/com/greensock/core/SimpleTimeline.as | 8 +-- src/com/greensock/loading/LoaderMax.as | 22 +++++-- src/com/greensock/loading/XMLLoader.as | 6 +- 7 files changed, 88 insertions(+), 77 deletions(-) diff --git a/src/com/greensock/TimelineLite.as b/src/com/greensock/TimelineLite.as index cab9e67..eb58167 100755 --- a/src/com/greensock/TimelineLite.as +++ b/src/com/greensock/TimelineLite.as @@ -1,6 +1,6 @@ /** - * VERSION: 12.0.2 - * DATE: 2013-02-21 + * VERSION: 12.0.3 + * DATE: 2013-02-28 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com/timelinelite/ **/ @@ -276,7 +276,7 @@ tl.add(nested); **/ public class TimelineLite extends SimpleTimeline { /** @private **/ - public static const version:String = "12.0.2"; + public static const version:String = "12.0.3"; /** @private **/ protected static const _paramProps:Array = ["onStartParams","onUpdateParams","onCompleteParams","onReverseCompleteParams","onRepeatParams"]; @@ -639,7 +639,7 @@ tl.fromTo(mc, 1, {x:0}, {x:100}, "myLabel+=2"); //places it 2 seconds after "my * @see #remove() */ public function fromTo(target:Object, duration:Number, fromVars:Object, toVars:Object, position:*="+=0"):* { - return add( TweenLite.fromTo(target, duration, fromVars, toVars), position); + return add(TweenLite.fromTo(target, duration, fromVars, toVars), position); } /** @@ -651,7 +651,7 @@ tl.fromTo(mc, 1, {x:0}, {x:100}, "myLabel+=2"); //places it 2 seconds after "my * * var textFields = [tf1, tf2, tf3, tf4, tf5]; -myTimeline.staggerTo(textFields, 1, {y:"+=150", ease:CubicIn.ease}, 0.2); +myTimeline.staggerTo(textFields, 1, {y:"+=150", ease:Cubic.easeIn}, 0.2); *

staggerTo() simply loops through the targets array and creates * a to() tween for each object and then inserts it at the appropriate place on a @@ -845,9 +845,7 @@ tl.staggerFromTo(myArray, 1, {x:0}, {x:100}, 0.25, "myLabel+=2"); //places 2 se toVars = _prepVars(toVars); fromVars = _prepVars(fromVars); toVars.startAt = fromVars; - if (fromVars.immediateRender) { - toVars.immediateRender = true; - } + toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); return staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams); } @@ -977,7 +975,11 @@ tl.set(mc, {x:100}, "myLabel+=2"); //places it 2 seconds after "myLabel" * @see #remove() */ public function set(target:Object, vars:Object, position:*="+=0"):* { - vars.immediateRender = false; + position = _parseTimeOrLabel(position, 0, true); + vars = _prepVars(vars); + if (vars.immediateRender == null) { + vars.immediateRender = (position === _time && !_paused); + } return add( new TweenLite(target, 0, vars), position); } @@ -1135,35 +1137,35 @@ tl.add([tween1, tween2, tween3], "+=2", "stagger", 0.5); if (typeof(position) !== "number") { position = _parseTimeOrLabel(position, 0, true, value); } - if (value is Animation) { - //continue... - } else if (value is Array) { - var i:int, - curTime:Number = Number(position), - l:Number = value.length, - child:*; - for (i = 0; i < l; i++) { - if ((child = value[i]) is Array) { - child = new TimelineLite({tweens:child}); - } - add(child, curTime); - if (typeof(child) === "string" || typeof(child) === "function") { - //do nothing - } else if (align === "sequence") { - curTime = child._startTime + (child.totalDuration() / child._timeScale); - } else if (align === "start") { - child._startTime -= child.delay(); + if (!(value is Animation)) { + if (value is Array) { + var i:int, + curTime:Number = Number(position), + l:Number = value.length, + child:*; + for (i = 0; i < l; i++) { + if ((child = value[i]) is Array) { + child = new TimelineLite({tweens:child}); + } + add(child, curTime); + if (typeof(child) === "string" || typeof(child) === "function") { + //do nothing + } else if (align === "sequence") { + curTime = child._startTime + (child.totalDuration() / child._timeScale); + } else if (align === "start") { + child._startTime -= child.delay(); + } + curTime += stagger; } - curTime += stagger; + return _uncache(true); + } else if (typeof(value) === "string") { + return addLabel(String(value), position); + } else if (typeof(value) === "function") { + value = TweenLite.delayedCall(0, value); + } else { + trace("Cannot add " + value + " into the TimelineLite/Max: it is neither a tween, timeline, function, nor a String."); + return this; } - return _uncache(true); - } else if (typeof(value) === "string") { - return addLabel(String(value), position); - } else if (typeof(value) === "function") { - value = TweenLite.delayedCall(0, value); - } else { - trace("Cannot add " + value + " into the TimelineLite/Max: it is neither a tween, timeline, function, nor a String."); - return this; } super.add(value, position); @@ -1502,9 +1504,9 @@ myAnimation.seek("myLabel"); } else if (tween._active || (tween._startTime <= _time && !tween._paused && !tween._gc)) { if (!tween._reversed) { - tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, false); + tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); } else { - tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, false); + tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); } } @@ -1519,9 +1521,9 @@ myAnimation.seek("myLabel"); } else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) { if (!tween._reversed) { - tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, false); + tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); } else { - tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, false); + tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); } } diff --git a/src/com/greensock/TimelineMax.as b/src/com/greensock/TimelineMax.as index 861b881..f2ee29a 100755 --- a/src/com/greensock/TimelineMax.as +++ b/src/com/greensock/TimelineMax.as @@ -1,6 +1,6 @@ /** - * VERSION: 12.0.2 - * DATE: 2013-02-21 + * VERSION: 12.0.3 + * DATE: 2013-02-28 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com/timelinemax/ **/ @@ -361,7 +361,7 @@ tl.add(nested); **/ public class TimelineMax extends TimelineLite implements IEventDispatcher { /** @private **/ - public static const version:String = "12.0.2"; + public static const version:String = "12.0.3"; /** @private **/ protected static var _listenerLookup:Object = {onCompleteListener:TweenEvent.COMPLETE, onUpdateListener:TweenEvent.UPDATE, onStartListener:TweenEvent.START, onRepeatListener:TweenEvent.REPEAT, onReverseCompleteListener:TweenEvent.REVERSE_COMPLETE}; /** @private **/ @@ -926,9 +926,9 @@ tl.add( myTimeline.tweenFromTo("myLabel2", 0) ); } else if (tween._active || (tween._startTime <= _time && !tween._paused && !tween._gc)) { if (!tween._reversed) { - tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, false); + tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); } else { - tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, false); + tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); } } @@ -943,9 +943,9 @@ tl.add( myTimeline.tweenFromTo("myLabel2", 0) ); } else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) { if (!tween._reversed) { - tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, false); + tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); } else { - tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, false); + tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); } } diff --git a/src/com/greensock/TweenLite.as b/src/com/greensock/TweenLite.as index 1f94657..e8153e3 100755 --- a/src/com/greensock/TweenLite.as +++ b/src/com/greensock/TweenLite.as @@ -1,6 +1,6 @@ /** - * VERSION: 12.0.2 - * DATE: 2013-02-21 + * VERSION: 12.0.3 + * DATE: 2013-02-28 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com **/ @@ -304,7 +304,7 @@ package com.greensock { public class TweenLite extends Animation { /** @private **/ - public static const version:String = "12.0.2"; + public static const version:String = "12.0.3"; /** Provides An easy way to change the default easing equation. Choose from any of the GreenSock eases in the com.greensock.easing package. @default Power1.easeOut **/ public static var defaultEase:Ease = new Ease(null, null, 1, 1); @@ -497,6 +497,9 @@ package com.greensock { vars.startAt.overwrite = 0; vars.startAt.immediateRender = true; _startAt = new TweenLite(target, 0, vars.startAt); + if (vars.immediateRender) { //tweens that render immediately (like most from() tweens) shouldn't revert when their parent timeline's playhead goes backward past the startTime because the initial render could have happened anytime and it shouldn't be directly correlated to this tween's startTime. Imagine setting up a complex animation where the beginning states of various objects are rendered immediately but the tween doesn't happen for quite some time - if we revert to the starting values as soon as the playhead goes backward past the tween's startTime, it will throw things off visually. Reversion should only happen in TimelineLite/Max instances where immediateRender was false (which is the default in the convenience methods like from()). + _startAt = null; + } } var i:int, initPlugins:Boolean, pt:PropTween; if (vars.ease is Ease) { @@ -790,6 +793,7 @@ package com.greensock { _firstPT = null; _overwrittenProps = null; _onUpdate = null; + _startAt = null; _initted = _active = _notifyPluginsOfEnabled = false; _propLookup = (_targets) ? {} : []; return this; @@ -956,12 +960,10 @@ TweenLite.fromTo([mc1, mc2, mc3], 1, {x:0}, {x:100}); * @see com.greensock.TweenMax#staggerFromTo() */ public static function fromTo(target:Object, duration:Number, fromVars:Object, toVars:Object):TweenLite { - toVars = _prepVars(toVars); + toVars = _prepVars(toVars, true); fromVars = _prepVars(fromVars); toVars.startAt = fromVars; - if (fromVars.immediateRender) { - toVars.immediateRender = true; - } + toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); return new TweenLite(target, duration, toVars); } diff --git a/src/com/greensock/TweenMax.as b/src/com/greensock/TweenMax.as index a85211d..146b3cd 100755 --- a/src/com/greensock/TweenMax.as +++ b/src/com/greensock/TweenMax.as @@ -1,6 +1,6 @@ /** - * VERSION: 12.0.2 - * DATE: 2013-02-21 + * VERSION: 12.0.3 + * DATE: 2013-02-28 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com **/ @@ -530,7 +530,7 @@ package com.greensock { */ public class TweenMax extends TweenLite implements IEventDispatcher { /** @private **/ - public static const version:String = "12.0.2"; + public static const version:String = "12.0.3"; TweenPlugin.activate([ @@ -1260,9 +1260,7 @@ TweenMax.fromTo([mc1, mc2, mc3], 1, {x:0}, {x:100}); toVars = _prepVars(toVars, false); fromVars = _prepVars(fromVars, false); toVars.startAt = fromVars; - if (fromVars.immediateRender) { - toVars.immediateRender = true; - } + toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); return new TweenMax(target, duration, toVars); } @@ -1388,6 +1386,9 @@ TweenMax.staggerFrom(textFields, 1, {y:"+150"}, 0.2); public static function staggerFrom(targets:Array, duration:Number, vars:Object, stagger:Number=0, onCompleteAll:Function=null, onCompleteAllParams:Array=null):Array { vars = _prepVars(vars, true); vars.runBackwards = true; + if (vars.immediateRender != false) { + vars.immediateRender = true; + } return staggerTo(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams); } @@ -1438,9 +1439,7 @@ TweenMax.staggerFromTo(textFields, 1, {alpha:1}, {alpha:0}, 0.2); toVars = _prepVars(toVars, false); fromVars = _prepVars(fromVars, false); toVars.startAt = fromVars; - if (fromVars.immediateRender) { - toVars.immediateRender = true; - } + toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false); return staggerTo(targets, duration, toVars, stagger, onCompleteAll, onCompleteAllParams); } diff --git a/src/com/greensock/core/SimpleTimeline.as b/src/com/greensock/core/SimpleTimeline.as index e4a0873..b74a740 100755 --- a/src/com/greensock/core/SimpleTimeline.as +++ b/src/com/greensock/core/SimpleTimeline.as @@ -1,6 +1,6 @@ /** - * VERSION: 12.0.0 - * DATE: 2013-01-21 + * VERSION: 12.0.3 + * DATE: 2013-02-28 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com **/ @@ -163,9 +163,9 @@ package com.greensock.core { next = tween._next; //record it here because the value could change after rendering... if (tween._active || (time >= tween._startTime && !tween._paused)) { if (!tween._reversed) { - tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, false); + tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force); } else { - tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, false); + tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force); } } tween = next; diff --git a/src/com/greensock/loading/LoaderMax.as b/src/com/greensock/loading/LoaderMax.as index fb892ed..a632725 100755 --- a/src/com/greensock/loading/LoaderMax.as +++ b/src/com/greensock/loading/LoaderMax.as @@ -1,6 +1,6 @@ /** - * VERSION: 1.933 - * DATE: 2013-02-22 + * VERSION: 1.934 + * DATE: 2013-02-28 * AS3 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/ **/ @@ -143,7 +143,7 @@ function errorHandler(event:LoaderEvent):void { */ public class LoaderMax extends LoaderCore { /** @private **/ - public static const version:Number = 1.933; + public static const version:Number = 1.934; /** The default value that will be used for the estimatedBytes on loaders that don't declare one in the vars parameter of the constructor. **/ public static var defaultEstimatedBytes:uint = 20000; /** Controls the default value of auditSize in LoaderMax instances (normally true). For most situations, the auditSize feature is very convenient for ensuring that the overall progress of LoaderMax instances is reported accurately, but when working with very large quantities of files that have no estimatedBytes defined, some developers prefer to turn auditSize off by default. Of course you can always override the default for individual LoaderMax instances by defining an auditSize value in the vars parameter of the constructor. **/ @@ -523,14 +523,15 @@ function completeHandler(event:LoaderEvent):void { * * @param status Status code like LoaderStatus.READY, LoaderStatus.LOADING, LoaderStatus.COMPLETED, LoaderStatus.PAUSED, or LoaderStatus.FAILED. * @param includeNested If true, loaders that are nested inside other loaders (like LoaderMax instances or XMLLoaders or SWFLoaders) will be returned in the array. + * @param omitLoaderMaxes If true, no LoaderMax instances will be returned in the array; only LoaderItems like ImageLoaders, XMLLoaders, SWFLoaders, MP3Loaders, etc. The default is false. * @return An array of loaders that match the defined status. * @see #getChildren() * @see #getLoader() * @see #numChildren */ - public function getChildrenByStatus(status:int, includeNested:Boolean=false):Array { + public function getChildrenByStatus(status:int, includeNested:Boolean=false, omitLoaderMaxes:Boolean=false):Array { var a:Array = []; - var loaders:Array = getChildren(includeNested, false); + var loaders:Array = getChildren(includeNested, omitLoaderMaxes); var l:int = loaders.length; for (var i:int = 0; i < l; i++) { if (LoaderCore(loaders[i]).status == status) { @@ -760,7 +761,7 @@ function completeHandler(event:LoaderEvent):void { var loader:LoaderCore, found:Boolean; for (var i:int = 0; i < l; i++) { loader = _loaders[i]; - if (!loader.auditedSize && loader.status <= maxStatus) { + if (!loader.auditedSize && loader.status <= maxStatus && loader.vars.auditSize != false) { if (!found) { loader.addEventListener("auditedSize", _auditSize, false, -100, true); loader.addEventListener(LoaderEvent.FAIL, _auditSize, false, -100, true); @@ -983,6 +984,13 @@ function completeHandler(event:LoaderEvent):void { return loader; } + override protected function _passThroughEvent(event:Event):void { + super._passThroughEvent(event); + if (!this.skipFailed && (event.type == "fail" || event.type == "childFail") && this.status == LoaderStatus.LOADING) { + super._failHandler(new LoaderEvent(LoaderEvent.FAIL, this, "Did not complete LoaderMax because skipFailed was false and " + event.target.toString() + " failed."), false); + } + } + //---- GETTERS / SETTERS ------------------------------------------------------------------------- @@ -1025,7 +1033,7 @@ function completeHandler(event:LoaderEvent):void { var maxStatus:int = (this.skipPaused) ? LoaderStatus.COMPLETED : LoaderStatus.PAUSED; var i:int = _loaders.length; while (--i > -1) { - if (!LoaderCore(_loaders[i]).auditedSize && LoaderCore(_loaders[i]).status <= maxStatus) { + if (!LoaderCore(_loaders[i]).auditedSize && LoaderCore(_loaders[i]).status <= maxStatus && _loaders[i].vars.auditSize != false) { return false; } } diff --git a/src/com/greensock/loading/XMLLoader.as b/src/com/greensock/loading/XMLLoader.as index a959a34..ef218c0 100755 --- a/src/com/greensock/loading/XMLLoader.as +++ b/src/com/greensock/loading/XMLLoader.as @@ -1,6 +1,6 @@ /** - * VERSION: 1.932 - * DATE: 2013-02-21 + * VERSION: 1.934 + * DATE: 2013-02-28 * AS3 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/ **/ @@ -229,7 +229,7 @@ function completeHandler(event:LoaderEvent):void { /** @private **/ private static var _classActivated:Boolean = _activateClass("XMLLoader", XMLLoader, "xml,php,jsp,asp,cfm,cfml,aspx"); /** @private Any non-String variable types that XMLLoader should recognized in loader nodes like , , etc. **/ - protected static var _varTypes:Object = {skipFailed:true, skipPaused:true, autoLoad:false, paused:false, load:false, noCache:false, maxConnections:2, autoPlay:false, autoDispose:false, smoothing:false, autoDetachNetStream:false, estimatedBytes:1, x:1, y:1, z:1, rotationX:1, rotationY:1, rotationZ:1, width:1, height:1, scaleX:1, scaleY:1, rotation:1, alpha:1, visible:true, bgColor:0, bgAlpha:0, deblocking:1, repeat:1, checkPolicyFile:false, centerRegistration:false, bufferTime:5, volume:1, bufferMode:false, estimatedDuration:200, crop:false, autoAdjustBuffer:true, suppressInitReparentEvents:true, allowMalformedURL:false}; + protected static var _varTypes:Object = {skipFailed:true, skipPaused:true, autoLoad:false, paused:false, load:false, noCache:false, auditSize:true, maxConnections:2, autoPlay:false, autoDispose:false, smoothing:false, autoDetachNetStream:false, estimatedBytes:1, x:1, y:1, z:1, rotationX:1, rotationY:1, rotationZ:1, width:1, height:1, scaleX:1, scaleY:1, rotation:1, alpha:1, visible:true, bgColor:0, bgAlpha:0, deblocking:1, repeat:1, checkPolicyFile:false, centerRegistration:false, bufferTime:5, volume:1, bufferMode:false, estimatedDuration:200, crop:false, autoAdjustBuffer:true, suppressInitReparentEvents:true, allowMalformedURL:false}; /** Event type constant for when the XML has loaded but has not been parsed yet. This can be useful in rare situations when you want to alter the XML before it is parsed by XMLLoader (for identifying LoaderMax-related nodes like <ImageLoader>, etc.) **/ public static var RAW_LOAD:String = "rawLoad"; /** @private contains only the parsed loaders that had the load="true" XML attribute. It also contains the _parsed LoaderMax which is paused, so it won't load (we put it in there for easy searching). **/