问题
So I was in the middle of making a type of test program where I would take parts of a shirt and the user could customize it with different colors.
While I was doing that I realized it wasn't realistic as there was absolutely no fade with the color picker tool (code shown below).
Is there any way to allow the user to use possibly a slider to change the level of tint on the color(s) being used on the shirt?
import fl.controls.ColorPicker;
import fl.events.ColorPickerEvent;
import flash.geom.ColorTransform;
var mycolor:ColorTransform = new ColorTransform();
cp.addEventListener(ColorPickerEvent.CHANGE,colorChanger);
function colorChanger(event:ColorPickerEvent):void{
mycolor.color = cp.selectedColor;
mc2.transform.colorTransform = mycolor;
}
import fl.events.SliderEvent;
import fl.controls.Slider;
var slider:Slider=new Slider();
slider.maximum=100;
slider.value=100;
addChild(slider);
slider.addEventListener(SliderEvent.THUMB_DRAG,changeAlpha);
function changeAlpha(event:SliderEvent):void{
mycolor.alphaMultiplier=slider.value/100;
mc2.transform.colorTransform = mycolor;
}
回答1:
Check this: flashandmath.com/howtos/tint
Very useful site, not only for tint! It's a big shame the authors don't really update it anymore. (but they still love flash, which is cool :o) )
回答2:
You only need to use mc2.alpha = slider.value/100 to change it.
来源:https://stackoverflow.com/questions/29808925/how-do-i-allow-user-to-select-tint-amount-in-flash-professional-using-actionscri