Jump to content
Search Community

Tweening coordinates one after another ? HELP

Applauz test
Moderator Tag

Recommended Posts

Hello,

 

I have a grid of 6 boxes set up as a row of 2 .. column of 3. The boxes are blue. I have a grey box that will move to whichever blue box is clicked.

 

The grey box starts as a default ontop of box1 ( top left box ).

 

If the user clicks for example box number 6 .. which would be the last box at the bottom right.. I want the grey box to tween down 2 boxes and to the right once. I need to do this for each box... to make the tween follow a path in a sense.

 

Can this be done with the greensock tools ?

 

 

Any help is appreciated.

 

Cheers!

Link to comment
Share on other sites

yes! any time you need to animated in Flash, the GreenSock Tweening Platform will make the job easy.

 

What you want to do consists of 5% GreenSock and 95% pure ActionScript.

 

the core of what you need to do is dynamically create a sequence of tweens, meaning each time the sequence runs, the ending x and y values will be different.

 

here is a very basic implementation:

 

import com.greensock.*;
OverwriteManager.init(2);

function moveSequence(mc, endX, endY){
  TweenLite.to(mc, .5, {x:endX});
  TweenLite.to(mc, .5, {y:endY, delay:.5});

}

moveSequence(box_mc, 100, 200);

 

the above will take a movie clip named box_mc and move it first to an x of 100, then a y of 200.

 

the above assumes:

1:you fla is saved in the same folder as the greensock com folder

2:you have a movie clip with instance name "box_mc" on the stage.

 

of course you will have a number of buttons that will pass in the x and y values, or perhaps you can just pass in a reference to the movie clip that the box_mc is moving to and the function will use the x and y of that movie clip.

 

the above is just an example of the core tweening-related concepts.

 

you could use TImelineLite/Max as well.

 

also you may want to detect if the box is in the same row as the destination, in which case you would omit the y tween. same goes for x.

 

 

I would suggest experimenting with what I provided. there are a half dozen ways of doing this.

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