Jump to content
Search Community

Adding tweens from function to timeline

alflasy test
Moderator Tag

Recommended Posts

Hi

I am trying to add tweens from function to timeline and it works fime when it plays but breaks when its reversed. Below is my code.

 

function startOverFlow(mcName,mcName2,v0,v1,v2,v3,v4,v5,v6,v7,v8) {
cfholder.setChildIndex(mcName, cfholder.numChildren - 1);
for(var d=0;d<9;d++){
	new TweenMax(cfTArr[d], 1, {autoAlpha:0})
}

//timeline.appendMultiple([
//trace(mcName)
new TweenMax(cfArr[0], 1, {x:cfArr[0].x-40,scaleY:v0,scaleX:v0,autoAlpha:v0}),
new TweenMax(cfArr[1], 1, {x:cfArr[1].x-40,scaleY:v1,scaleX:v1,autoAlpha:v1}),
new TweenMax(cfArr[2], 1, {x:cfArr[2].x-40,scaleY:v2,scaleX:v2,autoAlpha:v2}),
new TweenMax(cfArr[3], 1, {x:cfArr[3].x-40,scaleY:v3,scaleX:v3,autoAlpha:v3}),
new TweenMax(cfArr[4], 1, {x:cfArr[4].x-40,scaleY:v4,scaleX:v4,autoAlpha:v4}),
new TweenMax(cfArr[5], 1, {x:cfArr[5].x-40,scaleY:v5,scaleX:v5,autoAlpha:v5}),
new TweenMax(cfArr[6], 1, {x:cfArr[6].x-40,scaleY:v6,scaleX:v6,autoAlpha:v6}),
new TweenMax(cfArr[7], 1, {x:cfArr[7].x-40,scaleY:v7,scaleX:v7,autoAlpha:v7}),
new TweenMax(cfArr[8], 1, {x:cfArr[8].x-40,scaleY:v8,scaleX:v8,autoAlpha:v8}),
new TweenMax(mcName2, 1, {autoAlpha:1})

// ]) 
}

timeline.appendMultiple([new TweenMax(cfArr[7], 1, {onStart:startOverFlow,onStartParams:[cfArr[7],cfTArr[7],.3,.4,.5,.6,.7,.8,.9,1,.9]})],2);
timeline.appendMultiple([new TweenMax(cfArr[6], 1, {onStart:startOverFlow,onStartParams:[cfArr[6],cfTArr[6],.4,.5,.6,.7,.8,.9,1,.9,.8]})],1);
timeline.appendMultiple([new TweenMax(cfArr[5], 1, {onStart:startOverFlow,onStartParams:[cfArr[5],cfTArr[5],.5,.6,.7,.8,.9,1,.9,.8,.7]})],1);
timeline.appendMultiple([new TweenMax(cfArr[4], 1, {onStart:startOverFlow,onStartParams:[cfArr[4],cfTArr[4],.6,.7,.8,.9,1,.9,.8,.7,.6]})],1);
timeline.appendMultiple([new TweenMax(cfArr[3], 1, {onStart:startOverFlow,onStartParams:[cfArr[3],cfTArr[3],.7,.8,.9,1,.9,.8,.7,.6,.5]})],1);
timeline.appendMultiple([new TweenMax(cfArr[2], 1, {onStart:startOverFlow,onStartParams:[cfArr[2],cfTArr[2],.8,.9,1,.9,.8,.7,.6,.5,.4]})],1);
timeline.appendMultiple([new TweenMax(cfArr[1], 1, {onStart:startOverFlow,onStartParams:[cfArr[1],cfTArr[1],.9,1,.9,.8,.7,.6,.5,.4,.3]})],1);
timeline.appendMultiple([new TweenMax(cfArr[0], 1, {onStart:startOverFlow,onStartParams:[cfArr[0],cfTArr[0],1,.9,.8,.7,.6,.5,.4,.3,.2]})],1);

 

any idea.

 

Thanks

Link to comment
Share on other sites

your timeline doesn't appear to have any tweens in it at all. you are just using timeline.appendMultiple() to trigger startOverFlow to be called at different times which is then just creating a bunch of loose tweens not related to any TimelineMax.

 

I think you just need to shift your approach a bit.

 

start with a function that accepts a whole bunch of parameters and generates a TimelineMax which will be returned

 

function startOverFlow(mcName, mcName2, v0,v1,v2,v3,v4,v5,v6,v7,v8):TimelineMax{

var temp:TimelineMax = new TimelineMax();

//I really don't know what you are doing inside this function, but process those arguments however you have to so that your temp timeline is built the way you want.
//i'd suggest testing this approach in a much simpler setting.

cfholder.setChildIndex(mcName, cfholder.numChildren - 1);


  for(var d=0;d     temp.append( new TweenMax(cfTArr[d], 1, {autoAlpha:0}) )


  }

return temp;

}

 

 

then when you create your main timeline, append a series of TimelineMaxes that are returned by the startOverFlow function:

 

timeline.append(   startOverFlow(cfArr[7],cfTArr[7],.3,.4,.5,.6,.7,.8,.9,1,.9)  , 2  );
timeline.append(   startOverFlow(cfArr[6],cfTArr[6],.4,.5,.6,.7,.8,.9,1,.9,.8)  ,1   );

 

 

that's the general idea.

Link to comment
Share on other sites

This works for me be there are still some bugs

function startOverFlow(mcName,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9):TimelineMax{

var temp:TimelineMax = new TimelineMax();
temp.appendMultiple([new TweenMax(mcArr[0], 1, {x:mcArr[0].x-40,scaleY:v0,scaleX:v0,autoAlpha:v0,onStart:function(){
										mcholder.setChildIndex(mcName, mcholder.numChildren - 1)}}),
					 new TweenMax(mcArr[1], 1, {x:mcArr[1].x-40,scaleY:v1,scaleX:v1,autoAlpha:v1}),
					 new TweenMax(mcArr[2], 1, {x:mcArr[2].x-40,scaleY:v2,scaleX:v2,autoAlpha:v2}),
					 new TweenMax(mcArr[3], 1, {x:mcArr[3].x-40,scaleY:v3,scaleX:v3,autoAlpha:v3}),
					 new TweenMax(mcArr[4], 1, {x:mcArr[4].x-40,scaleY:v4,scaleX:v4,autoAlpha:v4}),
					 new TweenMax(mcArr[5], 1, {x:mcArr[5].x-40,scaleY:v5,scaleX:v5,autoAlpha:v5}),
					 new TweenMax(mcArr[6], 1, {x:mcArr[6].x-40,scaleY:v6,scaleX:v6,autoAlpha:v6}),
					 new TweenMax(mcArr[7], 1, {x:mcArr[7].x-40,scaleY:v7,scaleX:v7,autoAlpha:v7}),
					 new TweenMax(mcArr[8], 1, {x:mcArr[8].x-40,scaleY:v8,scaleX:v8,autoAlpha:v8})])

return temp;

}

timeline.append(startOverFlow(mcArr[1],.9,1,.9,.8,.7,.6,.5,.4,.3,.2));
timeline.append(startOverFlow(mcArr[2],.8,.9,1,.9,.8,.7,.6,.5,.4,.3));
timeline.append(startOverFlow(mcArr[3],.7,.8,.9,1,.9,.8,.7,.6,.5,.4));
timeline.append(startOverFlow(mcArr[4],.6,.7,.8,.9,1,.9,.8,.7,.6,.5));
timeline.append(startOverFlow(mcArr[5],.5,.6,.7,.8,.9,1,.9,.8,.7,.6));
timeline.append(startOverFlow(mcArr[6],.4,.5,.6,.7,.8,.9,1,.9,.8,.7));
timeline.append(startOverFlow(mcArr[7],.3,.4,.5,.6,.7,.8,.9,1,.9,.8));
timeline.append(startOverFlow(mcArr[8],.2,.3,.4,.5,.6,.7,.8,.9,1,.9));

 

In this line

new TweenMax(mcArr[1], 1, {x:mcArr[1].x-40,scaleY:v1,scaleX:v1,autoAlpha:v1}),

x:mcArr[1].x-40 is not updated. Looks like its not getting the updated position of all movies mcArr[1].x

 

Hope explain it right.

Link to comment
Share on other sites

try looping through mcArr and getting all the x values.

I don't know why one x value isn't updating.

its too difficult for me to visualize what may be happening in your file. I imagine this is actually a pretty cool effect you have created.

 

good job at getting it to follow the general format I suggested. it appears much neater.

 

just so you know, you can use relative values by putting quotes around your values.

 

TweenLite.to(mc, 1, {x:mc.x-40}) is the same as

 

TweenLite.to(mc, 1, {x:"-40"})

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...