Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

PIBC-QingYe

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by PIBC-QingYe

  1. Thanks @mikel, I have tested my thoughts, the tl.time() could compare labels'time well.
  2. I think I have find one way. Using the tl.time() to compare the label's time to judge reach which label. btn.addEventListener('click', function(){ var tl=new TimelineMax(); var obj=$("#entrance"); for(var i=0;i<4;i++){ var label="mylabel_"+i; tl.addLabel(label); if(i%2==1){ label="mylabel_"+i; tl.to(obj,5,{x:100+i*100, onUpdate: function(){ var panel=document.getElementById("test"); var t=tl.time().toFixed(2); for (var i = 0; i <labels.length; i++) { if(t>labels[i].time&&t<labels[i+1].time){ panel.innerHTML=labels[i].name; break; } }; }}); }else{ tl.to(obj,5,{y:100+i*100, onUpdate: function(){ var panel=document.getElementById("test"); var t=tl.time().toFixed(2); for (var i = 0; i <labels.length; i++) { if(t>labels[i].time&&t<labels[i+1].time){ panel.innerHTML=labels[i].name; break; } }; }}); } } tl.addLabel("mylabel_final"); var labels = tl.getLabelsArray(); for (var i = 0; i < labels.length; i++) { console.log("label name: " + labels[i].name + ", time: " + labels[i].time); }; }); But i'm not sure when using timescale() to change the play speed ,the tl.time() could compare labels'time well.
  3. Thanks mikel.The timeline has four animations,each of them has its own label.What i want to achieve are their labels.When each animation start , i want to use its label to change the panel's innerHTML.Just like your example,the value only show the last label.How to show the label "mylabel_0","mylabel_1","mylabel_2"when the timeline play?
  4. As the example,I want to use add() to create a callback function at each timeline's beginning,and use this to change the describe.But when it run,the callback function can't get the right value and the i became undefinded.
  5. Thank you,I find the problem.Just as you say,I use the same timline,so the animation play one by one.I change my object array and solve the problem. for (var i = 0; i < initnum; i++) { //init car[i] = { ... tl: new TimelineLite() }; }
  6. Thanks Jack,I have studied the tutorial which you given , but it can not solve my problem.Just like the following codes: var t = new TimelineLite(); var car = new Array(); for (var i = 0; i < initnum; i++) { //init car[i] = { id:xxx, name:xxx, tl: t }; } I give each car object a timeline and I want to play these timelines together.However I can only play these timelines one by one. for(var i=0;i<initnum;i++) { ... for (var j = 0; j <xxx; j++) { .... car[i].tl.to(obj,... ); car[i].tl.to(obj,... ); } car[i].tl.play(); } So how can I to play these timelines together.
  7. I need to show multiply cars' real-time track,so i try to create multiply timelinelite objects to fit cars.But when play these timelinelite objects,i find that they play one by one otherwise play together.How can i solve this problem.
×