“Color blink” effect with TweenMax

You could create a nice and smooth “color blink” effect for any DisplayObject, including TextField instances with a few lines of the code using TweenMax:

import com.greensock.easing.Cubic;
import com.greensock.plugins.ColorMatrixFilterPlugin;
import com.greensock.plugins.EndArrayPlugin;
import com.greensock.plugins.TweenPlugin;
import com.greensock.TweenMax;

/* run this line only once (as example, you can put it into the main document's constructor or your initialization function) */
TweenPlugin.activate([ColorMatrixFilterPlugin, EndArrayPlugin]);

/*and use this line later to start blinking */
TweenMax.to(anyDisplayObject, 1, {colorMatrixFilter:{colorize:0x74F88E, amount:1}, repeat:-1, yoyo:true, ease:Cubic.easeInOut} );

By the way, be careful with TintPlugin or ColorTransformPlugin while tweening TextFields with TweenMax – you can notice some lags or jerks in the tween animation.

Found a typo? Please, highlight it and press Shift + Enter or click here to inform me!

Share Button


“Color blink” effect with TweenMax — 2 Comments

  1. @fmaxx Я поначалу пробовал тинт, но он работал неравномерно на текстовых полях с html линками – дёргалась анимация (цвет не плавно менялся, а рывками), с colorMatrixFilter стало плавно. В конце поста я, кстати, упомянул про TintPlugin.

  2. я немного проще решил проблему:
    TweenMax.to(statusLabel, 1, {tint: 0xFFFFFF, repeat:-1, yoyo:true, ease:Cubic.easeInOut} );