4

Is there any other way to access the camera using ActionScript 3 other than

import flash.media.Camera;
videoInstance.attachCamera(cameraInstance);

Or should I use any API s? If so, please suggest me any API suitable and some tutorials if possible.

Thank You very much for helping. . .

My previous post on Camera is
How to increase the Quality of the camera using AS3?

Community
  • 1
  • 1
Raj A.N.T. Gounder
  • 490
  • 1
  • 6
  • 17

1 Answers1

5

If you need better Camera quality... check this ActionScript Mobile Flex Project.

This is the main file

package
{
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.ActivityEvent;
    import flash.events.MouseEvent;
    import flash.media.Camera;
    import flash.media.Video;

    public class iosTest extends Sprite
    {

        private var cam:Camera;
        private var vid:Video;


        public function iosTest()
        {
            super();

            // support autoOrients
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            cam = Camera.getCamera();

            if (!cam) 
            {
                trace("No camera is installed.");
            }
            else 
            {
                connectCamera();
            }
        }

        private function connectCamera():void 
        {
            cam.setMode(640, 480, 25); 
            cam.setQuality(0,100);
            vid             = new Video();
            vid.width       = cam.width;
            vid.height      = cam.height; 
            vid.attachCamera(cam);
            addChild(vid);    

            stage.addEventListener(MouseEvent.CLICK, clickHandler);
        }

        private function clickHandler(e:MouseEvent):void 
        {

            return;

            switch (cam.width) {
                case 160:
                    cam.setMode(320, 240, 10); 
                    break;
                case 320:
                    cam.setMode(640, 480, 5); 
                    break;
                default:
                    cam.setMode(160, 120, 15); 
                    break;
            } 
            removeChild(vid);           
            connectCamera();
        }

    }
}
Adrian Pirvulescu
  • 4,308
  • 3
  • 30
  • 47
  • @TiMeister... Thank you very much, I got what i needed. Any ways, is there any other ways to access the camera??? – Raj A.N.T. Gounder Jun 14 '11 at 07:01
  • I think this is the best way since it ensures it will get you the camera on any device. I am not aware of any other better ways... If your device has 2 cameras like iPhone 4 you can specify which one you want using Camera.getCamera(Index); – Adrian Pirvulescu Jun 14 '11 at 07:07