How do I allow user to select tint amount in Flash Professional using ActionScript 3?

﹥>﹥吖頭↗ 提交于 2020-01-06 21:11:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!