Jump to content
Search Community

colorTransform with repeat yoyo problem

demooo test
Moderator Tag

Recommended Posts

Hi guys!

 

Im stuck with a mini validation function that i've made.

When the user miss to fill in the textfield (that is in a mc) and click on the continue button, the field blinks red and returns to its original color.

But I found that if I click fast on the continue button more than once, it seems that the colorTransform adds the red color every time with a ending result of the mc getting red...

How do I prevent that? I want to, no matter how many times a user clicks the continue button, validate the field and every time get it to its original color.

 

import com.greensock.*;
import com.greensock.easing.*;

continueBtn.onRelease = function(){

//validate somefield, if not valid highlight it a couple times and return to original color
if( somefield.txt.length <= 0 || somefield.txt.text == "Write something here" ) {
	TweenMax.to(somefield, .2, {repeat:3, yoyo:true, colorTransform:{tint:0xff0000, tintAmount:0.5}});
	trace("validation fail on somefield");
	} else {
	   timelineOne.reverse();
	   timelineTwo.play();
        }

 

Thank you again for a such great package of classes, luv it :)

Link to comment
Share on other sites

Greetings.

 

the reason that is happening is that when you click fast, sometimes you are clicking when somefield is already red, so when it tweens to red there is nothing to tween to as it already is red, or when the yoyo/repeat ends... since it started on red... it ends on red.

 

the solution is to use a fromTo which allows you to specify the start and end values. This will allow your tween to always return to the initial starting values like so:

 

TweenMax.fromTo(somefield, .2, {colorTransform:{tint:null}}, {colorTransform:{tint:0xff0000, tintAmount:0.5}, repeat:3, yoyo:true});

 

http://www.greensock.com/as/docs/tween/ ... ml#fromTo()

 

enjoy

 

Carl

Link to comment
Share on other sites

Greetings.

 

the reason that is happening is that when you click fast, sometimes you are clicking when somefield is already red, so when it tweens to red there is nothing to tween to as it already is red, or when the yoyo/repeat ends... since it started on red... it ends on red.

 

the solution is to use a fromTo which allows you to specify the start and end values. This will allow your tween to always return to the initial starting values like so:

 

TweenMax.fromTo(somefield, .2, {colorTransform:{tint:null}}, {colorTransform:{tint:0xff0000, tintAmount:0.5}, repeat:3, yoyo:true});

 

http://www.greensock.com/as/docs/tween/ ... ml#fromTo()

 

enjoy

 

Carl

 

Thank you for your answer!

But I cant get it work..the only solution I come to is by doing like this:

 

if(!TweenMax.isTweening(somefield)){
TweenMax.to(somefield, .2, {repeat:3, yoyo:true, colorTransform:{tint:0xff0000, tintAmount:0.5}});
}

 

and it works good, but I dont know if it is a good solution..

Link to comment
Share on other sites

hmm

 

i made an example where instead of passing null into the colorTransform props I have a specific values.

 

cs3 fla attached. save it into your project folder.

 

i rapid-fired the button many many times and it always works.

 

Carl

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