Skip to content

Commit

Permalink
GSAP 12.0.3 and LoaderMax 1.934
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
jackdoyle committed Mar 1, 2013
1 parent 9cd6e31 commit abe855b
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 77 deletions.
82 changes: 42 additions & 40 deletions 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/
**/
Expand Down Expand Up @@ -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"];

Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -651,7 +651,7 @@ tl.fromTo(mc, 1, {x:0}, {x:100}, "myLabel+=2"); //places it 2 seconds after "my
*
* <listing version="3.0">
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);
</listing>
* <p><code>staggerTo()</code> simply loops through the <code>targets</code> array and creates
* a <code>to()</code> tween for each object and then inserts it at the appropriate place on a
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

}
Expand All @@ -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);
}

}
Expand Down
14 changes: 7 additions & 7 deletions 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/
**/
Expand Down Expand Up @@ -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 **/
Expand Down Expand Up @@ -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);
}

}
Expand All @@ -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);
}

}
Expand Down
16 changes: 9 additions & 7 deletions 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
**/
Expand Down Expand Up @@ -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 <code>com.greensock.easing</code> package. @default Power1.easeOut **/
public static var defaultEase:Ease = new Ease(null, null, 1, 1);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -790,6 +793,7 @@ package com.greensock {
_firstPT = null;
_overwrittenProps = null;
_onUpdate = null;
_startAt = null;
_initted = _active = _notifyPluginsOfEnabled = false;
_propLookup = (_targets) ? {} : [];
return this;
Expand Down Expand Up @@ -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);
}

Expand Down
17 changes: 8 additions & 9 deletions 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
**/
Expand Down Expand Up @@ -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([

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions 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
**/
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 15 additions & 7 deletions 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/
**/
Expand Down Expand Up @@ -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 <code>estimatedBytes</code> on loaders that don't declare one in the <code>vars</code> parameter of the constructor. **/
public static var defaultEstimatedBytes:uint = 20000;
/** Controls the default value of <code>auditSize</code> in LoaderMax instances (normally <code>true</code>). 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 <code>estimatedBytes</code> 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 <code>auditSize</code> value in the <code>vars</code> parameter of the constructor. **/
Expand Down Expand Up @@ -523,14 +523,15 @@ function completeHandler(event:LoaderEvent):void {
*
* @param status Status code like <code>LoaderStatus.READY, LoaderStatus.LOADING, LoaderStatus.COMPLETED, LoaderStatus.PAUSED,</code> or <code>LoaderStatus.FAILED</code>.
* @param includeNested If <code>true</code>, loaders that are nested inside other loaders (like LoaderMax instances or XMLLoaders or SWFLoaders) will be returned in the array.
* @param omitLoaderMaxes If <code>true</code>, no LoaderMax instances will be returned in the array; only LoaderItems like ImageLoaders, XMLLoaders, SWFLoaders, MP3Loaders, etc. The default is <code>false</code>.
* @return An array of loaders that match the defined <code>status</code>.
* @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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 -------------------------------------------------------------------------

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit abe855b

Please sign in to comment.