IsDon Posted August 7, 2013 Share Posted August 7, 2013 Hi, I'm creating an animation on the stage (a base class) made up of subclasses which return a TimelineLite for their animations. The problem seems to be that creating a timelineLite auto-plays the timeline that was created, rather than just being available for the parent timeline. Its a wierd one, because it creates wierd movement only apparent for the first 5-10s (period of an individual animation). Is there a better way to create a timeline or tween object and pass it up the chain for use later? This is pretty much the code I use now: public function animMe():TimelineLite { var tl:TimelineMax = new TimelineMax({ onStart:function() { this.visible=true; }, onComplete:function() { this.visible=false; } }); if(myTransitions.length>0) { //myTransitions is an array of morphs to perform var j; var obj:*; for(j=0;j<myTransitions.length;j++) { obj = myTransitions[j][0]; if(obj) { tl.append( obj.morph(myTransitions[j]) ); //(morph function below) } } } else { tl.append( TweenLite.delayedCall( 0.1, trace, [this.name + " skipping. (no transitions found)"] ) ); } return tl;}public function morph(trans:Array):TimelineLite { var obj1 = trans[0]; var params1 = trans[1]; //params for .to function eg. {x:"-55"} or {alpha:1} var delay1 = trans[2]; var tl:TimelineLite = new TimelineLite({delay: delay1}); if(obj1.invalid == true) return tl; if("bm" in obj1) { //add blitmask update function if present in object params1.onUpdate = obj1.bm.update; params1.onUpdateParams = [null, true]; } tl.append( TweenLite.to( obj1,anim_dur,params1 ) ); return tl;} Thanks, (I'm loving greensock library) Don have a great day Link to comment Share on other sites More sharing options...
jamiejefferson Posted August 7, 2013 Share Posted August 7, 2013 I'm not exactly sure I understand the weird movement problem you're seeing, but maybe the following might help? You can create your timelines so that they are initially paused, and then unpause them when adding them to a parent timeline. This way they are just being built up and not actually playing until you really need them to, which should help avoid most synchronisation issues e.g. var mastertl:TimelineLite = new TimelineLite({ paused: true }); var anim:TimelineLite = animMe(); // anim is paused at this point mastertl.add(anim.paused(false)); // mastertl is still paused, so anim will not 'play' yet mastertl.play(); // mastertl is now playing so anim will progress as well public function animMe():TimelineLite { var tl:TimelineLite = new TimelineLite({ paused: true }); // add some tweens return tl; } Note: a paused timeline will remain paused even if it is added to another timeline - it must be unpaused if you want it to respect the playhead of its parent and play along. Link to comment Share on other sites More sharing options...
IsDon Posted August 7, 2013 Author Share Posted August 7, 2013 Thanks for the reply, On thinking about it, I think on my previous project I got around this with overwriteManager = "always". Another thing I was toying with today was the idea of using a paused timeline in the subclass, then passing tl.tweenFromTo("start","middle") to the parent. - Would that pass a valid tween if the tl is paused in the object? Don have a great day Link to comment Share on other sites More sharing options...
IsDon Posted August 8, 2013 Author Share Posted August 8, 2013 I found I needed to force a function call from the 0 point on the parent timeline to each subobject which turned its alpha or visibility off. This way when the parent timeline hits the subobject's part of the timeline, it then tweens on from 0. mastertl.add( element[i].hideMe(), 0 ); //add a visibility = 0, alpha = 0 function at start Donhave a great day Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now