tweenmax. overlapping of tweens

Hi, I'm using greensock tweenmax and are having a problem of overlapping tweens

I have several panels placed in a vertical manner. Each one acts as a button. When you click on one of the panels the panels bellow it move down 142 pixels. I placed my actions in a movieclilp and for each panel there is a frame with a label. In each label there is a frame with the actions for all the panels. This way I was able to assign a different script for the panels that were moved when I activated one of the panels.

Everything works great except that when I click back and forth between two panels the tweened distance adds up. I think that is what the overlapping feature is for but it's not working well.

Here's the code without the overlapping script
import gs.TweenMax;
import gs.TweenGroup;
import gs.easing.*;
_root.W.masterheadlab.onPress = function() {
	TweenGroup.allTo([_root.W.kokocompany, _root.W.banianhome, _root.W.jonashidalgo, _root.W.sandislone, _root.W.saffronliving, _root.W.pleca],1,{_y:"142"},TweenMax);
	_root.W.masterheadlab.enabled = false;
	_root.W.kokocompany.enabled = true;
_root.W.kokocompany.onPress = function() {
	TweenGroup.allTo([_root.W.banianhome, _root.W.jonashidalgo, _root.W.sandislone, _root.W.saffronliving, _root.W.pleca],1,{_y:"142"},TweenMax);
	_root.W.masterheadlab.enabled = true;
	_root.W.kokocompany.enabled = false;

Open in new window

Who is Participating?
Hi cristobal_ny,

Here you go, I rewrite all the code for you, hope it works for you. =)
Hi cristobal_ny,

The problem occur because the animation for the tween is not yet completed animating and then you click on back, let say we click back then before the back animation done we click on forth, take for example your bar will have to move 20 pixel down from 200 to Y axis at 180  the correct location but when you click on forth the back animation might be only move until 190 and before it completed and stop at location Y axis at 200 you click on forth and move 20 pixel up again then it will move from 190 back to 210 this will add 10 pixel to the original location it suppose to stop at, so it will increase the distance between, to prevent that your can disable the button or movieclip once your click on any of it then enable back the button or movieclip after the animation done this will prevent the distance becoming closer.

You can try click on back and forth but wait till the animation have done then only your click on forth, then your will see why it is getting closer if your click on back and forth very fast.
cristobal_nyAuthor Commented:
Yes that is the problem that when you click on different buttons before the tweens are finished the remaining distances are added to the new tweened distance.
But what is the solution??????
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hi cristobal_ny,

Youneed to calculate the current y of your movieclip then minus the next location your going to stop.

Let say now your movieclip is at Y location 180, your next location to reach when you click on forth is 200, so once your click on forth and when you click on back your will need to calculate the actual distance need to go back to 180 let say when you click on back your movieclip is now animate until Y location 190 then it will be 190 - 180, you will need to ask the tween function to move 10 to reach back to your previous location.

You get my point? or you can upload your fla I can take a look at your code. Hope you understand. =)
cristobal_nyAuthor Commented:
thank you, I uploded the fla file
But regarding your solution, the distance that remains when you click before it each tween ends varies depending on when you activate another tween. So I don't think it's practical. I am sure that that's what the overwrite function in greensocks website

note: for the fla file to work you need to download the tweenmax AS2 from the website
cristobal_nyAuthor Commented:
Thank you so much for taking the time to make the fla file! I works fine!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.