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

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

问题描述

我用AdjustColor \的ColorMatrixFilter改变颜色(亮度,对比度,色调,饱和度)的元素(remoteVideo),这是使用滑块控制的。我的问题是标签RESET颜色的按钮被点击的四个滑块时

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

就搬回0它们的默认位置,但只有对比度和饱和度复位。我也试图消除调用函数adjustColor()和重复包含没有成功的函数中相同的步骤。

更新:我也试过filter.matrix = NULL;                 remoteVideo.filters = NULL;但同样的问题仍然有效。

库:

 进口flash.display.Sprite;
        进口fl.motion.AdjustColor;
        进口flash.filters.ColorMatrixFilter;
        进口fl.events.SliderEvent;
        进口的flash.external.ExternalInterface;
 

变量:

  //颜色变化

        私人VAR颜色:AdjustColor =新AdjustColor(); //这个对象将持有的颜色属性
        私人VAR过滤器:的ColorMatrixFilter =新的ColorMatrixFilter(); //将存储修改后的彩色滤光器改变视频
 

功能:

 私有函数resetColors(E:事件= NULL):无效
        {

            //所有滑块重置为0
            BrightnessSlider.value = 0;
            ContrastSlider.value = 0;
            HueSlider.value = 0;
            SaturationSlider.value = 0;

            adjustColor();

        }

        私有函数adjustColor(E:事件= NULL):无效
        {
            color.brightness = BrightnessSlider.value;
            color.contrast = ContrastSlider.value;
            color.hue = HueSlider.value;
            color.saturation = SaturationSlider.value;
            filter.matrix = color.CalculateFinalFlatArray();
            remoteVideo.filters = [过滤器]



        }
 

GUI:

 < S:NavigatorContent标签=调整颜色启用={currentState的= LoginNotConnected!}>
            < S:布局>
                &所述氏:Horizo​​ntalLayout />
            < / S:布局>

            &所述氏:VGroup>
                &所述氏:HGroup>
                    < S:面板宽度=247HEIGHT =67.5的backgroundColor =0xA0A0​​A0
                             标题=亮度>
                        < S:布局>
                            < S:VerticalLayout以下属性来=8/>
                        < / S:布局>
                        < S:使用HSlider ID =BrightnessSliderWIDTH =220
                                   更改=adjustColor(事件)最大=100最低= -  100
                                   showDataTip =假值=0/>
                    < / S:面板>

                    < S:面板宽度=247HEIGHT =67.5的backgroundColor =0xA0A0​​A0
                             标题=对比度>
                        < S:布局>
                            < S:VerticalLayout以下属性来=8/>
                        < / S:布局>
                        < S:使用HSlider ID =ContrastSliderWIDTH =220改变=adjustColor(事件)
                                   最大=100最低= -  100showDataTip =假值=0/>
                    < / S:面板>
                &所述; /秒:HGroup>

                &所述氏:HGroup>

                    < S:面板宽度=247HEIGHT =67.5的backgroundColor =0xA0A0​​A0称号=色相>
                        < S:布局>
                            < S:VerticalLayout以下属性来=8/>
                        < / S:布局>
                        < S:使用HSlider ID =HueSliderWIDTH =220改变=adjustColor(事件)
                                   最大=180最小= -  180showDataTip =假值=0/>
                    < / S:面板>
                    < S:面板宽度=247HEIGHT =67.5的backgroundColor =0xA0A0​​A0
                             标题=饱和度>
                        < S:布局>
                            < S:VerticalLayout以下属性来=8/>
                        < / S:布局>
                        < S:使用HSlider ID =SaturationSliderWIDTH =220
                                   更改=adjustColor(事件)最大=100最低= -  100
                                   showDataTip =假值=0/>



                    < / S:面板>


                &所述; /秒:HGroup>

                < S:按钮标签=RESET COLORS点击=resetColors(事件)的styleName =按钮样式/>


            &所述; /秒:VGroup>




        &所述; /秒:NavigatorContent>
 

解决方案

在你的 resetColors 功能,您不需要调用 adjustColor 。删除它并将其替换 remoteVideo.filters = NULL;

 私有函数resetColors(E:事件= NULL):无效
    {
        //所有滑块重置为0
        BrightnessSlider.value = 0;
        ContrastSlider.value = 0;
        HueSlider.value = 0;
        SaturationSlider.value = 0;
        remoteVideo.filters = NULL;
    }
 

I'm using AdjustColor\ColorMatrixFilter to change the Color (Brightness, Contrast, Hue, Saturation) of an Element (remoteVideo), which is controlled using Sliders. 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; 

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.

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

Libraries:

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

Variables:

// 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

Function:

        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]; 



        } 

GUI:

        <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>

解决方案

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天全站免登陆