How to mirror camera display in VideoDisplay in Flex

663 Views Asked by At

I am trying to mirror the camera display in my mx:VideoDisplay object in Flex 3.6. That is, I want the camera image to be flipped horizontally.

This is my MXML file:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
                layout="absolute" applicationComplete="init()"
                xmlns:ns1="components.*" 
                xmlns:ns2="*"
                xmlns:fl="flash.media.*"
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:gauge="components.gauge.*"
                >
<mx:Script source="script.as" />
<mx:Style source="style.css" />
        <mx:Canvas label="recorder" width="100%" height="100%" verticalScrollPolicy="off" 
            horizontalScrollPolicy="off" id="canvas2">
            <mx:VideoDisplay id="myWebcam"  scaleX="1"  left="0" top="0" bottom="36" right="0"/>
            <mx:Image id="mask2" source="@Embed(source='assets/mask.png')"                          
                    left="190" top="120" width="270"/> 
    <ns1:VideoContainer right="0" bottom="0" /> 
</mx:Application>

I have tried to use myWebcam.scaleX="-1" and adding myWebcam.x = myWebcam.width among many further combinations without success.

So, how am I supposed to flip the image?

Thanks

1

There are 1 best solutions below

0
BearPy On

You can change:

<mx:VideoDisplay id="myWebcam"  scaleX="1"  left="0" top="0" bottom="36" right="0"/>

to:

<mx:VideoDisplay id="myWebcam"  scaleX="-1"  left="0" top="0" bottom="36" right="0" x="{myWebcam.width + myWebcam.x}"/>

I also found that myWebcam.scaleX = -1 is not ok, maybe it is a bug.