Jump to content
Search Community

cannot set Timeline align property to "normal"

isaacalves test
Moderator Tag

Recommended Posts

Hello,

 

I would like to append (prepend actually) tweens in a timeline one by one, in a for loop (instead of using the appendMultiple).

But when I do it this way, using append() or prepend(), the tweens don't get aligned as it was supposed to ("normal"), they are aligned like in sequence. If I use insert() they align correctly... in cases like these I've been using insert() instead of append(), but now I would like to prepend(), so, how do I do? Why doesn't it align correctly?

 

			timeline = new TimelineLite({delay: 1, paused: true, align: "normal"});

		for (var i:int; i < _totalCubes; i++){

			var _cube:Cube = new Cube(materialsList, _cubeW, _cubeD, _cubeH);
			_cube.x = -2000;
			_cube.rotationY = 15;

			_cubeVarsObj = {x: (_xOffset + _cubeW)*i - (_xOffset + _cubeW)*(_totalCubes*.5),
							y: 0}

			scene.addChild(_cube);

			timeline.prepend(TweenLite.to(_cube, 1, {x: _cubeVarsObj.x, delay: 0.1*i, ease:Quart.easeOut}));
		}

		timeline.play();

 

Well I know there are thousand of ways to do what i need there, but I would like to understand why the TimelineLite behaves like that..

 

Thanks in advance!

Link to comment
Share on other sites

I'm confused - you want to prepend() but you don't want it to put the tween BEFORE all the others? The entire notion of "prepend()" hinges on that concept. That's the sole purpose of having the prepend() method. append() adds a tween AFTER all the other tweens in the timeline, prepend() adds it BEFORE all the other tweens, and insert() gives you total control over the placement regardless of where other tweens are.

 

Am I missing something?

 

If you want to put them all at the beginning, the correct way would be to insert() them at the time of 0 (that's the default anyway). Or you could just put all those tweens from your loop into their own TimelineLite and then prepend() that TimelineLite to the other one. :)

Link to comment
Share on other sites

Yeah, you're right ...it makes sense :)

 

I wanted to insert the tweens and put a delay on each one and multiply the delay by "i" ,but I would like to reverse that order . So the cube created in the first iteration would get the biggest delay.

So I solved that by switching a plus and a minus operator on this line (I inverted the order of the target X for each cube) :

 

				_cubeVarsObj = {x: -(_xOffset + _cubeW)*i + (_xOffset + _cubeW)*(_totalCubes*.5), y: 0};

 

:)

 

thanks for clearing that out for me.

cheers!

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...