按钮功能不正常(重置AdjustColors)

时间:2015-09-09 00:17:50

标签: actionscript-3 flash flex actionscript

我正在使用AdjustColor \ ColorMatrixFilter来更改元素(remoteVideo)的颜色(亮度,对比度,色调,饱和度),这是使用滑块控制的。

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

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

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

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

库:

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

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>

0 个答案:

没有答案