Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Highlighted
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus
Accepted Solution

How to add camera to view?

public function initCamera():void
            {
                camera=Camera.getCamera("0");
               
                if(camera!=null)
                {
                    camera.setMode(2592, 1456, 48);
                    camera.setQuality(0, 100);   
                   
                   
                    video=new Video(972, 546);
                    video.attachCamera(camera);
                    video.x=0;
                    video.y=0;
                   
                    stage.addChild(video);
                   
                }
            }

 I call this method the my view "creationComplete" event. But the Camera Viewfinder isnt displayed on my app..

 

Any thought on how to display the camera feed to the app??

Please..

 

Thank you all..

www.jackdevora.com
Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: How to add camera to view?

Instead of using video object, use CameraUI Class

 

Create object of CameraUI like

var myCam : CameraUI = new CameraUI();

and to open camera to have images or to have video follow it

 

myCam.launch(MediaType.IMAGE); // to get camera to click image.

myCam.launch(MediaType.VIDEO); // to get camera to get video

 

Me saying to use of cameraUI class because if you are having both landscape and portrait mode in your application, using camera.getCamera, you need to set the video resolution on change of screen. SO you'd better to use CameraUI class rather then using it. 

 

Developer
Posts: 75
Registered: ‎09-13-2011
My Device: Playbook
My Carrier: None

Re: How to add camera to view?

check out http://www.unitedmindset.com/jonbcampos/2010/09/29/air-for-android-camera-and-camera-roll/ these code samples and explanations really cleared things up for me. 



Show your support and click on the like button when you see a post that was helpful.
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: How to add camera to view?

Really good article there ChappyK.

But since I am still 2 days old into ActionScript. I figured that my real problem is. How to add the "Sprite" object to my Application view..

 

<fx:Script>
	<![CDATA[
		import components.CameraSprite;
		import mx.core.UIComponent;
				

					
		public function initCamera():void
		{
		 var camera:CameraSprite=new CameraSprite();
		 
		 addChild(camera);
		}

		]]>
	</fx:Script>
	

 Is the code above a correct way to add a Sprite into the view?

 

Sorry for the dumb question..

www.jackdevora.com
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: How to add camera to view?

Thanks for the reply.. But what I need was Camera instead of Camera UI, since i need to have more control over the camera..
www.jackdevora.com
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: How to add camera to view?

Please ignore it, I figured it out..Thanks a lot ChappyK for the code
www.jackdevora.com
Developer
Posts: 75
Registered: ‎09-13-2011
My Device: Playbook
My Carrier: None

Re: How to add camera to view?

no question is dumb, and glad you figured it out. I'm assuming it was giving you trouble with addChild(...)? if thats the case you should be using UIComponent and addElement(...). It might be helpful to others if you post a short sample of what you did, for others. Happy coding Smiley Wink



Show your support and click on the like button when you see a post that was helpful.
Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: How to add camera to view?

Is there a standard way you launch the video/camera application and save images that can be used in your app using only AS3 w/o mxml??

 

It would be useful just to provide the code to press button, open camera, snap picture, save dialog, capture save location and or change name of picture, close camera.

 

Developers in the greater community would benefit from knowing how to achieve this simple operation.