Jump to content
Search Community

[basics] tween in for loop

Pygmy test
Moderator Tag

Recommended Posts

I know it have to be simple and it should probably work with onUpdate and onUpdateParams but I dont know how to do it.

I have 'for' loop changing x and y variables. Generaly its about moving object from point to point - but tween is going straight to last point.

 

for (var m:uint=0; m		var XX=board.getChildAt(player.field).x;  //new x
	var YY=board.getChildAt(player.field).y;  //new y
	moveBoard(XX,YY);
	player.field++;
			}

public function moveBoard(xx:Number,yy:Number):void {
	TweenMax.to(table,1, {x:(x-xx)+stageW*.5, y:(y-yy)+stageH*.5});
}

 

Thank you for any help.

Link to comment
Share on other sites

Your code is just creating a bunch of x/y tweens for the same object (table) that all start immediately, so they overwrite each other. It sounds like you want a sequence. In that case, you'd want to either use the "delay" special property so that they occur one-after-the-other, or use a TimelineLite, like:

var timeline:TimelineLite = new TimelineLite();
for (var m:uint = 0; m       var XX=board.getChildAt(player.field).x;  //new x
     var YY=board.getChildAt(player.field).y;  //new y
     timeline.append( TweenMax.to(table, 1,  {x:(x-XX)+stageW*.5, y:(y-YY)+stageH*.5}) );
     player.field++;
}

 

This relies on using v11 which you can get at http://blog.greensock.com/v11beta/

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