按钮无法正常工作(重置 AdjustColors) [英] Button is not functioning properly (Resetting AdjustColors)

查看:33
本文介绍了按钮无法正常工作(重置 AdjustColors)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AdjustColor\ColorMatrixFilter 来更改使用滑块控制的元素(远程视频)的颜色(亮度、对比度、色调、饱和度).

I'm using AdjustColor\ColorMatrixFilter to change the Color (Brightness, Contrast, Hue, Saturation) of an Element (remoteVideo), which is controlled using Sliders.

我的问题是当带有 RESET COLORS 标签的按钮被点击时四个滑块

My issue is when the button with the label RESET COLORS is clicked the four sliders

BrightnessSlider.value = 0; 
ContrastSlider.value = 0; 
HueSlider.value = 0; 
SaturationSlider.value = 0; 

确实移回它们的默认位置 0,但仅重置对比度和饱和度.我还尝试删除对函数 adjustColor() 的调用并重复该函数中包含的相同步骤,但没有成功.

do move back to their default position of 0, but only the Contrast and Saturation is reset. I've also tried removing the call to the function adjustColor() and repeating the same steps contained within that function without success.

更新:我也试过 filter.matrix = null;remoteVideo.filters = null;但同样的问题仍然存在.

Update: I also tried filter.matrix = null; remoteVideo.filters = null; but the same issue still stands.

图书馆:

import flash.display.Sprite;
import fl.motion.AdjustColor;
import flash.filters.ColorMatrixFilter;
import fl.events.SliderEvent;   
import flash.external.ExternalInterface;

变量:

// color change
private var color:AdjustColor = new AdjustColor(); //This object will hold the color properties
private var filter:ColorMatrixFilter = new ColorMatrixFilter(); //Will store the modified color filter to change the video

功能:

private function resetColors(e:Event = null):void
{

    // reset all sliders to 0
    BrightnessSlider.value = 0; 
    ContrastSlider.value = 0; 
    HueSlider.value = 0; 
    SaturationSlider.value = 0; 

    adjustColor();

}

private function adjustColor(e:Event = null):void 
{ 
    color.brightness = BrightnessSlider.value; 
    color.contrast = ContrastSlider.value; 
    color.hue = HueSlider.value; 
    color.saturation = SaturationSlider.value; 
    filter.matrix = color.CalculateFinalFlatArray(); 
    remoteVideo.filters = [filter];     
} 

图形界面:

<s:NavigatorContent label="ADJUST COLORS" enabled="{currentState != LoginNotConnected}">
    <s:layout>
        <s:HorizontalLayout/>
    </s:layout>

    <s:VGroup>
        <s:HGroup>
            <s:Panel width="247" height="67.5" backgroundColor="0xA0A0A0"
                             title="Brightness">
                <s:layout>
                    <s:VerticalLayout paddingLeft="8"/>
                </s:layout>
                <s:HSlider id="BrightnessSlider" width="220" change="adjustColor(event)" maximum="100" minimum="-100" showDataTip="false" value="0"/>
            </s:Panel>

            <s:Panel width="247" height="67.5" backgroundColor="0xA0A0A0"
                             title="Contrast">
                <s:layout>
                    <s:VerticalLayout paddingLeft="8"/>
                </s:layout>
                <s:HSlider id="ContrastSlider" width="220" change="adjustColor(event)"
                                   maximum="100" minimum="-100" showDataTip="false" value="0"/>
            </s:Panel>
        </s:HGroup>

        <s:HGroup>
            <s:Panel width="247" height="67.5" backgroundColor="0xA0A0A0" title="Hue">
                <s:layout>
                    <s:VerticalLayout paddingLeft="8"/>
                </s:layout>
                <s:HSlider id="HueSlider" width="220" change="adjustColor(event)" maximum="180" minimum="-180" showDataTip="false" value="0"/>
            </s:Panel>
            <s:Panel width="247" height="67.5" backgroundColor="0xA0A0A0"
                             title="Saturation">
                <s:layout>
                    <s:VerticalLayout paddingLeft="8"/>
                </s:layout>
                <s:HSlider id="SaturationSlider" width="220"
                                   change="adjustColor(event)" maximum="100" minimum="-100" showDataTip="false" value="0"/>
            </s:Panel>

        </s:HGroup>

        <s:Button label="RESET COLORS" click="resetColors(event)" styleName="buttonStyle"/>
    </s:VGroup>

</s:NavigatorContent>

推荐答案

在您的 resetColors 函数中,您不需要调用 adjustColor.删除它并替换为 remoteVideo.filters = null;

In your resetColors function you don't need the call to adjustColor. Remove it and replace it with remoteVideo.filters = null;

    private function resetColors(e:Event = null):void
    {
        // reset all sliders to 0
        BrightnessSlider.value = 0; 
        ContrastSlider.value = 0; 
        HueSlider.value = 0; 
        SaturationSlider.value = 0;
        remoteVideo.filters = null;
    }

这篇关于按钮无法正常工作(重置 AdjustColors)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆