We help IT Professionals succeed at work.

Tint Tweener

TheYan
TheYan asked
on
I need to tint an image, in my function there is a tweener, like this:

Tweener.addTween(evt.target.object,{alpha:0.5,time:1,transition:"regular"});

Open in new window


Instead of alpha (50%) I want it to be tint by 50%, how can it be done?
Comment
Watch Question

Top Expert 2010

Commented:
You can control tinting as well as alpha by using the Color object and its setTransform().  

Author

Commented:
can you modify the code above to work?
Try this (assuming the color of the object was set to "0x000000" initially). It should display all colors available in a 10 second interval ... as color is a simple uint with the highest level bits controlling "red", the mid-level bits controlling "green" and the lowest-level bist controlling "blue". Think this example is relatively unpractical, but it should get you the idea.

Tweener.addTween(evt.target.object,{color:0xffffff,time:10,transition:"regular"});

Open in new window

Author

Commented:
The color does not change, nothing happens, if instead of "color" I put "_color" then it will replace the image with that color. Any other ways of making it work?
Top Expert 2009
Commented:
you're right, Tweener uses the underscore syntax for AS2 and AS3 (very confusing) - have a look at snippet below.
it think you're missing your colorshortcuts.

import caurina.transitions.properties.ColorShortcuts;
import caurina.transitions.Tweener;
ColorShortcuts.init();


bob.addEventListener(MouseEvent.CLICK, doTween);

function doTween(e:MouseEvent):void
{
      Tweener.addTween(objClip, {_color:0x0FFFFFF, time:10, transition:"regular"});
}
Geee ... you're right blue-genie ...

the properties without "_" control the tween and the ones with control the target properties. Can I sum it up to that?
Top Expert 2009

Commented:
Hey Christofer - i was just reading the asker's last post again.

"then it will replace the image with that color. Any other ways of making it work?"
that's what a tint will do to an image. you can't "colorise" it like you would in photoshop.