A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to correct mirror image shown by webcam using action script 3.0

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    3

    How to correct mirror image shown by webcam using action script 3.0

    Hello
    Using Flash CS5.5 and action script 3 I have made a small application for image capturing through web cam and integrated it in php page working perfect also save image. But problem is it shows MIRROR image on screen means if I move my right hand on screen it shows left hand. My query is how can I correct this setting. Here is the code -
    Code:
    package take_picture_fla
    {
        import com.adobe.images.*;
        import flash.display.*;
        import flash.events.*;
        import flash.media.*;
        import flash.net.*;
        import flash.ui.*;
        import flash.utils.*;
    
        dynamic public class MainTimeline extends MovieClip
        {
            public var capture_mc:MovieClip;
            public var bitmap:Bitmap;
            public var rightClickMenu:ContextMenu;
            public var snd:Sound;
            public var video:Video;
            public var bitmapData:BitmapData;
            public var warn:MovieClip;
            public var save_mc:MovieClip;
            public var bandwidth:int;
            public var copyright:ContextMenuItem;
            public var cam:Camera;
            public var quality:int;
    
            public function MainTimeline()
            {
                addFrameScript(0, frame1);
                return;
            }// end function
    
            public function onSaveJPG(event:Event) : void
            {
                var myEncoder:JPGEncoder;
                var byteArray:ByteArray;
                var header:URLRequestHeader;
                var saveJPG:URLRequest;
                var urlLoader:URLLoader;
                var sendComplete:Function;
                var e:* = event;
                sendComplete = function (event:Event) : void
                {
                    warn.visible = true;
                    addChild(warn);
                    warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown);
                    warn.buttonMode = true;
                    return;
                }// end function
                ;
                myEncoder = new JPGEncoder(100);
                byteArray = myEncoder.encode(bitmapData);
                header = new URLRequestHeader("Content-type", "application/octet-stream");
                saveJPG = new URLRequest("save.php");
                saveJPG.requestHeaders.push(header);
                saveJPG.method = URLRequestMethod.POST;
                saveJPG.data = byteArray;
                urlLoader = new URLLoader();
                urlLoader.addEventListener(Event.COMPLETE, sendComplete);
                urlLoader.load(saveJPG);
                return;
            }// end function
    
            public function warnDown(event:MouseEvent) : void
            {
                navigateToURL(new URLRequest("images/"), "_blank");
                warn.visible = false;
                return;
            }// end function
    
            function frame1()
            {
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
                rightClickMenu = new ContextMenu();
                copyright = new ContextMenuItem("Developed By www.webinfopedia.com Go to Application");
                copyright.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, myLink);
                copyright.separatorBefore = false;
                rightClickMenu.hideBuiltInItems();
                rightClickMenu.customItems.push(copyright);
                this.contextMenu = rightClickMenu;
                snd = new camerasound();
                bandwidth = 0;
                quality = 100;
                cam = Camera.getCamera();
                cam.setQuality(bandwidth, quality);
                cam.setMode(320, 240, 30, false);
                video = new Video();
                video.attachCamera(cam);
                video.x = 20;
                video.y = 20;
                addChild(video);
                bitmapData = new BitmapData(video.width, video.height);
                bitmap = new Bitmap(bitmapData);
                bitmap.x = 360;
                bitmap.y = 20;
                addChild(bitmap);
                capture_mc.buttonMode = true;
                capture_mc.addEventListener(MouseEvent.CLICK, captureImage);
                save_mc.alpha = 0.5;
                warn.visible = false;
                return;
            }// end function
    
            public function captureImage(event:MouseEvent) : void
            {
                snd.play();
                bitmapData.draw(video);
                save_mc.buttonMode = true;
                save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
                save_mc.alpha = 1;
                return;
            }// end function
    
            public function myLink(event:Event)
            {
                navigateToURL(new URLRequest("http://www.webinfopedia.com/export-database-data-to-excel-in-php.html"), "_blank");
                return;
            }// end function
    
        }
    }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    bitmap.scaleX *= -1;

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Hello fruitbeard! Long time I haven't see you overhere hehe hope you are ok

    Yeah when I read this thread title I quickly thought "scaleX *= -1" to flip orizontally!
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Of course you did Angel, here is a quick example to mess around with and utilise within your file vishalonne.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center