Jump to content
Search Community

colorMatrixFilter overwrite? [SOLVED]

isaballoon test
Moderator Tag

Recommended Posts

Jack, loving your new platform. Spent the past weekend kicking the tires.

 

Question, in using the following code I'm discovering that the brightness tweens in the 'over' and 'out' functions seem to be overwriting the tweens in the clickHandler function. What's the story here? Not sure what to do about this. Any help is greatly appreciated.

 

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

var clipArray:Array = [one, two, three, four, five];

for (var i:int = 0; i < clipArray.length; i++) {
clipArray[i].buttonMode = true;
clipArray[i].addEventListener(MouseEvent.CLICK, clickHandler);
clipArray[i].addEventListener(MouseEvent.ROLL_OVER, over);
clipArray[i].addEventListener(MouseEvent.ROLL_OUT, out);
}

function clickHandler(event:MouseEvent):void {
for (var i:int = 0; i < clipArray.length; i++) {
	if (event.currentTarget == clipArray[i]) {
		clipArray[i].mouseEnabled = false;
		clipArray[i].buttonMode = false;
		TweenMax.to(clipArray[i], 1, {colorMatrixFilter:{brightness:2}});
	} else {
		clipArray[i].mouseEnabled = true;
		clipArray[i].buttonMode = true;
		clipArray[i].alpha = 1;
		TweenMax.to(clipArray[i], 1, {colorMatrixFilter:{brightness:1}});
	}
}
}

function over(event:MouseEvent):void {
TweenMax.to(event.currentTarget, .3, {colorMatrixFilter:{brightness:1.3}});
}
function out(event:MouseEvent):void {
TweenMax.to(event.currentTarget, .3, {colorMatrixFilter:{brightness:1}});
}

Link to comment
Share on other sites

Sorry, it doesn't throw errors, I mispoke. What happens is it doesn't execute the colorMatrixFilter tweens in the clickHandler function. Definitely feels like an overwrite issue. Happy to send over the fla if that helps. I stripped the file down to just the five mcs (buttons).

Link to comment
Share on other sites

Yeah i am sorta having a problem with the same thing... not sure if I have it setup correctly

 

tl.insert(TweenMax.to(myText,.4,{glowFilter:{color:0x0000FF, alpha:1,strength:9, blurX:100, blurY:50}}),0);

tl.insert(TweenMax.to(myText,.12,{glowFilter:{color:0xFFFFFF, alpha:1,strength:2, blurX:1.5, blurY:1.5,overwrite:false}}),0);

 

the second one kills the first one :(

Link to comment
Share on other sites

The problem is that you're toggling the mouseEnabled property to false which immediately triggers a ROLL_OUT event. See for yourself by removing all the TweenMax code and just put trace()s in the various handlers. So I'm pretty darn sure this has absolutely nothing to do with TweenMax - it's just the order in which your handlers are getting called.

 

Does that help?

Link to comment
Share on other sites

Yeah i am sorta having a problem with the same thing... not sure if I have it setup correctly

 

tl.insert(TweenMax.to(myText,.4,{glowFilter:{color:0x0000FF, alpha:1,strength:9, blurX:100, blurY:50}}),0);

tl.insert(TweenMax.to(myText,.12,{glowFilter:{color:0xFFFFFF, alpha:1,strength:2, blurX:1.5, blurY:1.5,overwrite:false}}),0);

 

the second one kills the first one :(

 

You have two tweens affecting the same property of the same object at the same time - what were you expecting to happen? (that wasn't a slam - I'm literally trying to understand what you were hoping for)

Link to comment
Share on other sites

The problem is that you're toggling the mouseEnabled property to false which immediately triggers a ROLL_OUT event. See for yourself by removing all the TweenMax code and just put trace()s in the various handlers. So I'm pretty darn sure this has absolutely nothing to do with TweenMax - it's just the order in which your handlers are getting called.

 

Does that help?

 

Hm. If I replace the TweenMax code with simple alpha settings (commented out in the code) it works just fine for me. I get the tween on the "click" and I get alpha changes on rollOver and rollOut. If I get the alpha changes shouldn't I be able to get tweens as well? This is what is confusing me here and leading me to believe it's a conflict with the tweens. I did what you suggested replacing tweens with traces and it seems to me all the actions are triggering as they should.

 

I still think it's a tweening thing. Regardless, I do appreciate your taking time to look into it as always. Thank you.

Link to comment
Share on other sites

If I get the alpha changes shouldn't I be able to get tweens as well? This is what is confusing me here and leading me to believe it's a conflict with the tweens. I did what you suggested replacing tweens with traces and unless I'm looking at the wrong things it seems to me all the actions are triggering as they should.

 

I still think it's a tweening thing. Regardless, I do appreciate your taking time to look into it as always. Thank you.

 

I think you may be misunderstanding the order of the calls. Let's say, for example, that you click on the mc "one". It calls clickHandler() which in turn creates a colorMatrixFilter brightness tween to a value of 2. Since inside that method you ALSO immediately set mouseEnabled to false, it then calls the out() event which you have creating ANOTHER colorMatrixFilter brightness tween to a value of 1. So you have TWO tweens of the same property of the same object occurring at the same time. TweenMax is smart enough to have the 2nd one (the one that was created last) overwrite the first one (otherwise you'd have to conflicting tweens that are fighting to control the same property of the same object). See the issue now?

Link to comment
Share on other sites

you ALSO immediately set mouseEnabled to false, it then calls the out() event

 

This is the part I'm not understanding... why setting mouseEnabled to false calls the 'out' event. If anything it seems the 'over' is the one that might be called since the mouse is currently over 'one.' That being the case the overwrite makes sense of course. I'm just not sure what the solution is just yet. By the way I wasn't calling into question your coding of TweenMax. I expected the shortcoming was on my end. Thanks for your time.

Link to comment
Share on other sites

No worries. I wasn't offended :)

 

The reason Flash dispatches a ROLL_OUT event when you change mouseEnabled to false is because you had it in a state that indicated the mouse was over the object, but if the mouse is no longer enabled for that object, Flash can't really leave it in a ROLL_OVER state (that would indicate that the mouse is over it even though it's not supposed to be able to recognize that), so it fires the ROLL_OUT event one last time before ignoring the mouse altogether.

Link to comment
Share on other sites

My thought was to run the tween then call the disabling upon its completion. My attempt (see below) didn't work however..

 

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

var clipArray:Array = [one, two, three, four, five];

for (var i:int = 0; i < clipArray.length; i++) {
clipArray[i].buttonMode = true;
clipArray[i].addEventListener(MouseEvent.CLICK, clickHandler);
clipArray[i].addEventListener(MouseEvent.ROLL_OVER, over);
clipArray[i].addEventListener(MouseEvent.ROLL_OUT, out);
}

function clickHandler(event:MouseEvent):void {
for (var i:int = 0; i < clipArray.length; i++) {
	if (event.currentTarget == clipArray[i]) {
		//TweenMax.to(clipArray[i], 1, {colorMatrixFilter:{brightness:2}});
		TweenMax.to(clipArray[i], 1, {colorMatrixFilter:{brightness:2}, onComplete: disable});
	} else {
		clipArray[i].mouseEnabled = true;
		clipArray[i].buttonMode = true;
		clipArray[i].alpha = 1;
		TweenMax.to(clipArray[i], 1, {colorMatrixFilter:{brightness:1}});
	}
	function disable():void {
		clipArray[i].mouseEnabled = false;
		clipArray[i].buttonMode = false;
	}
}
}

function over(event:MouseEvent):void {
TweenMax.to(event.currentTarget, .3, {colorMatrixFilter:{brightness:1.5}});
}
function out(event:MouseEvent):void {
TweenMax.to(event.currentTarget, .3, {colorMatrixFilter:{brightness:1}});

Link to comment
Share on other sites

If your goal is to prevent that out() tween from running when the user clicks, you could just add conditional logic like so:

 

function out(event:MouseEvent):void {
  if (event.target.mouseEnabled) {
      TweenMax.to(event.currentTarget, .3, {colorMatrixFilter:{brightness:1}});
  }
}

 

Sorry, I don't have much time to think through alternatives right now (rushing on a few projects), but hopefully this helps.

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