-
How change tint on mc rollover using AS3
Apologies if this is an old question, but I found no answers after scouring the web. I have a movie clip I've placed with actionscript 3. I currently have the code set to change the alpha levels on rollover, but would prefer to change the tint instead. I understand I need to use a color transform, but am having a hard time seeing how to apply it.
My current code, changing the alpha levels on rollover, is here:
//Function for thumbnail rollovers
mc.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
mc.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
function mouseOver(event:MouseEvent):void {
event.target.alpha = .7;
}
function mouseOut(event:MouseEvent):void {
event.target.alpha = 1;
}
Does anyone know how I can change this code to apply
a tint, let's say 50% of #000000, instead of changing
the alpha levels?
-
why dont you use TweenLiteFilter?
-
you have to grab the object transform.colorTransform object. then you can make adjustments to either the offsets (-255 is darkest, 255 is brightest) or multipliers (decimal value). there are red, green, blue and alpha offsets, as well as multipliers. then you reassign that colortransform to the objects transform.colorTransform.
here's basically what you want
PHP Code:
function mouseOver(event:MouseEvent):void {
var trans = event.currentTarget.transform.colorTransform;
trans.redOffset = -100;
trans.blueOffset = -100;
trans.greenOffset = -100;
event.currentTarget.transform.colorTransform = trans;
}
function mouseOut(event:MouseEvent):void {
var trans = event.currentTarget.transform.colorTransform;
trans.redOffset = 0;
trans.blueOffset = 0;
trans.greenOffset = 0;
event.currentTarget.transform.colorTransform = trans;
}
-
Thank you-that expained it in a way I could understand!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|