Jump to content
Search Community

Bug with blurFilter and child alpha tween?

BladePoint test
Moderator Tag

Recommended Posts

I've been able to reproduce this bug using some simple code. Any insight on what is causing it would be appreciated.

 

What you should have is a container with a slightly 3D rotated green square on top of a larger red square. The red square fades in and out on a loop. The container is blurred. A more complex version of that is what I would like to happen in my actual project.

 

But what really happens is that the moment the blurFilter is turned on, the green square disappears while the red square continues to fade in and out. When the blurFilter is removed, the green square comes back.

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

var blurSprite:Sprite = new Sprite();
//This is the sprite to be blurred that will contain two child objects.
//It will contain a red square with a smaller green square on top of it.

var red_under:Sprite = new Sprite();
//This is the red square child which will be under the green square child.
red_under.graphics.beginFill(0xff0000);
red_under.graphics.drawRect(0,0,100,100);
red_under.graphics.endFill();
red_under.x = 225;
red_under.y = 150;
red_under.alpha = 0;
TweenMax.to(red_under,1,{alpha:1,repeat:-1,yoyo:true});
//The red square starts with alpha = 0 and tweens to alpha = 1 on a yoyo loop.
blurSprite.addChild(red_under);

var green_over:Sprite = new Sprite();
//This is the green square which will be on top of the red square.
green_over.graphics.beginFill(0x00ff00);
green_over.graphics.drawRect(0,0,80,80);
green_over.graphics.endFill();
green_over.x = 235;
green_over.y = 160;
green_over.rotationX = -10;
//The rotationX is key to reproducing this bug. Without it, the bug doesn't
//occur. Unfortunately my real project needs it.
blurSprite.addChild(green_over);
addChild(blurSprite);

TweenMax.to(blurSprite,0,{blurFilter:{blurX:4,blurY:4,quality:1},delay:1});
//You can see the green square disappear when the blurFilter kicks in after
//a 1 second delay
TweenLite.delayedCall(4,TweenMax.to,[blurSprite,0,{blurFilter:{blurX:4,blurY:4,quality:1,remove:true}}]);
//To test that the blurFilter is really causing the green square
//to disappear, I remove the blurFilter after a delay of 4
//seconds. When that happens the green square magically reappears.
Link to comment
Share on other sites

That is definitely a Flash bug that's unrelated to GSAP. You can test for yourself by removing TweenLite/Max from the equation:

import flash.filters.BlurFilter;

var blurSprite:Sprite = new Sprite();

var red_under:Sprite = new Sprite();
red_under.graphics.beginFill(0xff0000);
red_under.graphics.drawRect(0,0,100,100);
red_under.graphics.endFill();
red_under.x = 225;
red_under.y = 150;
blurSprite.addChild(red_under);

var green_over:Sprite = new Sprite();
green_over.graphics.beginFill(0x00ff00);
green_over.graphics.drawRect(0,0,80,80);
green_over.graphics.endFill();
green_over.x = 235;
green_over.y = 160;
green_over.rotationX = -10;

blurSprite.addChild(green_over);
addChild(blurSprite);

blurSprite.filters = [new BlurFilter()];    
setTimeout(function() {
	red_under.alpha = 0.5;
	//if you uncomment the next line, it appears to work!
	//blurSprite.rotationX = blurSprite.rotationX;
}, 100);

Notice that if you re-apply the 3D rotation after the alpha is changed, it appears to fix things (yeah, silly, I know). So you could try adding an onUpdate to your alpha tween that re-applies the 3D rotation to your other object. I'd also encourage you to file a bug with Adobe. 

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