I'm trying to allow the user to set the Brightness, Contrast, Hue, and Saturation for the remote users Camera (this will just affect the local user that is adjusting the preferences) with a Slider. I don't see a class for this here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html# so I used the libraries below to set the element "remoteVideo" (the remote camera) to whatever the user desires for Brightness, Contrast, Hue, and Saturation. I'm getting a syntax error for color.brightness.remoteVideo(0, BrightnessSlider.value); (and for Contrast, Hue, and Saturation) that says (Multiple Markers at this Line. 1119: Access of Undefined property brightess through a reference with fl.motion.adjustcolor & - Access of undefined property remoteVideo, which is clearly defined since the RTMFP Video Chat works\compiles fine without the code below:
( Original Sourcecode without my changes below if it helps: https://github.com/MonaSolutions/MonaClients/blob/master/VideoPhone/src/VideoPhone.mxml )
// Libraries for Brightness Contrast Hue Saturation
import flash.display.Sprite;
import fl.motion.AdjustColor;
import flash.filters.ColorMatrixFilter;
import fl.events.SliderEvent;
import flash.external.ExternalInterface;
// variables for Brightness Contrast Hue Saturation
private var color:AdjustColor = new AdjustColor(); //This object will hold the color properties
private var filter:ColorMatrixFilter; //Will store the modified color filter to change the video
// FIXED functions
private function BrightnessLevel(e:Event = null):void
{
color.brightness = BrightnessSlider.value;
var mMatrix:Array = color.CalculateFinalFlatArray();
filter = new ColorMatrixFilter(mMatrix);
remoteVideo.filters = [filter];
status("Setting brightness to: " + BrightnessSlider.value + "\n");
}
private function ContrastLevel(e:Event = null):void
{
color.contrast = ContrastSlider.value;
var mMatrix:Array = color.CalculateFinalFlatArray();
filter = new ColorMatrixFilter(mMatrix);
remoteVideo.filters = [filter];
status("Setting contrast to: " + ContrastSlider.value + "\n");
}
private function HueLevel(e:Event = null):void
{
color.hue = HueSlider.value;
var mMatrix:Array = color.CalculateFinalFlatArray();
filter = new ColorMatrixFilter(mMatrix);
remoteVideo.filters = [filter];
status("Setting hue to: " + HueSlider.value + "\n");
}
private function SaturationLevel(e:Event = null):void
{
color.saturation = SaturationSlider.value;
var mMatrix:Array = color.CalculateFinalFlatArray();
filter = new ColorMatrixFilter(mMatrix);
remoteVideo.filters = [filter];
status("Setting saturation to: " + SaturationSlider.value + "\n");
}
// sliders for Brightness Contrast Hue Saturation
<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="BrightnessLevel(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="ContrastLevel(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="HueLevel(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="SaturationLevel(event)" maximum="100" minimum="-100"
showDataTip="false" value="0"/>
</s:Panel>
</s:HGroup>
</s:VGroup>
</s:NavigatorContent>
Based on the documentation for AdjustColor, each of those properties (brightness, contrast, hue, saturation) is a Number. So this line:
color.brightness.remoteVideo(0, BrightnessSlider.value);
is trying to access the property remoteVideo
from color.brightness
which is a Number. It's telling you that there is no property "remoteVideo" on Number.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/motion/AdjustColor.html
Edit: Something like this may or may not work: (I haven't tested this)
color.brightness = BrightnessSlider.value;
var mMatrix:Array = color.CalculateFinalFlatArray();
filter = new ColorMatrixFilter(mMatrix);
remoteVideo.filters = [filter];
You can avoid creating a new Filter constantly by instantiating it once and just updating its matrix property.
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 BrightnessLevel(e:Event = null):void
{
status("Setting brightness to: " + BrightnessSlider.value + "\n");
color.brightness = BrightnessSlider.value;
applyFilter();
}
private function ContrastLevel(e:Event = null):void
{
status("Setting contrast to: " + ContrastSlider.value + "\n");
color.contrast = ContrastSlider.value;
applyFilter();
}
private function HueLevel(e:Event = null):void
{
status("Setting hue to: " + HueSlider.value + "\n");
color.hue = HueSlider.value;
applyFilter();
}
private function SaturationLevel(e:Event = null):void
{
status("Setting saturation to: " + SaturationSlider.value + "\n");
color.saturation = SaturationSlider.value;
applyFilter();
}
private function applyFilter():void
{
filter.matrix = color.CalculateFinalFlatArray();
remoteVideo.filters = [filter];
}