Jump to content
Search Community

TweenLite tint flickering

shanethehat test
Moderator Tag

Recommended Posts

Hi,

 

I'm trying to change the tint on a sprite in a loop. This works fine, but when I place another sprite at a higher depth that contains a gradient, the tint animation flickers. Any idea why, or how to prevent it?

 

package  {
import com.greensock.plugins.TintPlugin;
import com.greensock.plugins.TweenPlugin;
import com.greensock.TweenLite;
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.events.Event;
import flash.display.Sprite;
public class Background extends Sprite
{
	private var colorClip			:Sprite;
	private var gradClip			:Sprite;

	private var nextColor			:int = 1;

	private var colors			:Array = new Array(0xff0000,
										     0x00ff00,
										     0x0000ff
										     );

	public function Background():void
	{
		TweenPlugin.activate([TintPlugin]);
		if(stage) {
			init();
		} else {
			addEventListener(Event.ADDED_TO_STAGE,init);
		}
	}

	private function init(evt:Event = null):void
	{
		colorClip = addChild(new Sprite()) as Sprite;
		colorClip.graphics.beginFill(colors[0]);
		colorClip.graphics.drawRect(0,0,654,274);

		var mat:Matrix = new Matrix();
		mat.createGradientBox(654,274,toRad(-90));
		gradClip = addChild(new Sprite()) as Sprite;
		gradClip.graphics.beginGradientFill(GradientType.LINEAR, [0x000000,0x000000], [.7,0], [0,255],mat);
		gradClip.graphics.drawRect(0,0,654,274);
		gradClip.cacheAsBitmap = true;

		startColorTimer();
	}

	private function startColorTimer():void
	{
		TweenLite.delayedCall(4,changeColor);
	}

	public function changeColor():void
	{
		TweenLite.killTweensOf(changeColor);
		TweenLite.to(colorClip,1,{tint:colors[nextColor],onComplete:startColorTimer});
		(nextColor+1 < colors.length)?nextColor++:nextColor=0;
	}

               private function toRad(a:Number):Number 
	{
		return a*Math.PI/180;
	}
}
}

Link to comment
Share on other sites

hmm, not really. my gut says this is more of a Flash Player issue than a GreenSock issue.

 

if you attach and fla or swf, perhaps one of us can verify whether or not it happens for everyone.

 

very strange.

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