Packagecom.diadraw.extensions.camera
Classpublic class NativeCameraDriver
InheritanceNativeCameraDriver Inheritance flash.events.EventDispatcher

NativeCameraDriver is the main interface for communicating with the native camera.



Public Methods
 MethodDefined By
  
NativeCameraDriver(_target:IEventDispatcher = null)
Constructor
NativeCameraDriver
  
dispose():void
Destructor
NativeCameraDriver
  
hasTorch():Boolean
Checks whether the device has a torch.
NativeCameraDriver
  
isAndroid():Boolean
[static] Checks if we are running on Android.
NativeCameraDriver
  
isiOS():Boolean
[static] Checks if we are running on iOS.
NativeCameraDriver
  
setCropRectanglePixels(_x:Number, _y:Number, _w:Number, _h:Number):void
Allows you to define a rectangle for cropping the frame.
NativeCameraDriver
  
setExposureMode(_mode:Number, _pointOfInterest:Point = null):void
Sets the exposure mode.
NativeCameraDriver
  
setFocusMode(_mode:Number, _pointOfInterest:Point = null):void
Sets the focus mode.
NativeCameraDriver
  
setPointOfInterest(_pointCoordinates:Point, _displaySize:Point, _stage:Stage):void
Determines a particular point of interest for which to adjust focus, exposure and white balance.
NativeCameraDriver
  
setRotationAngle(_angleDegrees:Number):void
Allows you to rotate the frame by an arbitrary angle, measured in degrees.
NativeCameraDriver
  
setTorchMode(_mode:Number):void
Sets the torch mode, if the device has a torch.
NativeCameraDriver
  
setTranslationPoint(_offsetX:Number, _offsetY:Number):void
Allows you to translate the frame.
NativeCameraDriver
  
setWhiteBalanceMode(_mode:Number):void
Sets the white balance mode.
NativeCameraDriver
  
startCameraPreview(_stage:Stage, _settings:CameraSettings = null):Boolean
Starts the video stream and dispatches NativeCameraDriverEvent.CAMERA_STARTED is dispatched if the camera has started successfully.
NativeCameraDriver
  
Stops the video stream.
NativeCameraDriver
  
Allows you to switch between the front and the back camera at runtime.
NativeCameraDriver
Public Constants
 ConstantDefined By
  ERROR_COULD_NOT_ACQUIRE_BYTE_ARRAY : Number = -10
[static]
NativeCameraDriver
  ERROR_COULD_NOT_RELEASE_BYTE_ARRAY : Number = -11
[static]
NativeCameraDriver
  ERROR_ERROR_DURING_COPY : Number = -7
[static]
NativeCameraDriver
  ERROR_EXCEPTION_THROWN_DURING_COPY : Number = -8
[static]
NativeCameraDriver
  ERROR_EXCEPTION_THROWN_DURING_COPY_NO_INFO : Number = -9
[static]
NativeCameraDriver
  ERROR_NO_DATA_IN_RESERVE_BUFFER : Number = -4
[static]
NativeCameraDriver
  ERROR_NO_NEW_DATA : Number = -5
[static]
NativeCameraDriver
  ERROR_NO_READ_BUFFER : Number = -2
[static]
NativeCameraDriver
  ERROR_NO_RESERVE_BUFFER : Number = -3
[static]
NativeCameraDriver
  ERROR_UNKNOWN : Number = -1
[static]
NativeCameraDriver
  ERROR_ZERO_LENGTH_DATA : Number = -6
[static]
NativeCameraDriver
Constructor Detail
NativeCameraDriver()Constructor
public function NativeCameraDriver(_target:IEventDispatcher = null)

Constructor

Parameters
_target:IEventDispatcher (default = null)
Method Detail
dispose()method
public function dispose():void

Destructor

hasTorch()method 
public function hasTorch():Boolean

Checks whether the device has a torch. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Returns
Boolean
isAndroid()method 
public static function isAndroid():Boolean

Checks if we are running on Android.

Returns
Boolean
isiOS()method 
public static function isiOS():Boolean

Checks if we are running on iOS.

Returns
Boolean
setCropRectanglePixels()method 
public function setCropRectanglePixels(_x:Number, _y:Number, _w:Number, _h:Number):void

Allows you to define a rectangle for cropping the frame. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_x:Number — Crop rectangle left coordinate in pixels.
 
_y:Number — Crop rectangle top coordinate in pixels.
 
_w:Number — Crop rectangle width in pixels.
 
_h:Number — Crop rectangle height in pixels.

setExposureMode()method 
public function setExposureMode(_mode:Number, _pointOfInterest:Point = null):void

Sets the exposure mode. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_mode:Number — Use one of the CameraSettings.ExposureModeconstants
 
_pointOfInterest:Point (default = null) — Optional point of interest, which is supported on some devices. (0, 0) corresponds to the top left and (1, 1) - to the bottom right of the picture area with the home button on the right - applies even if the device is in portrait mode.

See also

setFocusMode()method 
public function setFocusMode(_mode:Number, _pointOfInterest:Point = null):void

Sets the focus mode. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_mode:Number — Use one of the CameraSettings.FocusModeconstants
 
_pointOfInterest:Point (default = null) — Optional point of interest, which is supported on some devices. (0, 0) corresponds to the top left and (1, 1) - to the bottom right of the picture area with the home button on the right - applies even if the device is in portrait mode.

See also

setPointOfInterest()method 
public function setPointOfInterest(_pointCoordinates:Point, _displaySize:Point, _stage:Stage):void

Determines a particular point of interest for which to adjust focus, exposure and white balance. Use this to allow the user to select a point by tapping on the display. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_pointCoordinates:Point — The coordinates of the point of interest in the image's coordinate system.
 
_displaySize:Point — The size of the image preview.
 
_stage:Stage — A reference to the stage.

setRotationAngle()method 
public function setRotationAngle(_angleDegrees:Number):void

Allows you to rotate the frame by an arbitrary angle, measured in degrees. You can use this to allow finger gestures to rotate the preview. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_angleDegrees:Number — The rotation angle in degrees

setTorchMode()method 
public function setTorchMode(_mode:Number):void

Sets the torch mode, if the device has a torch. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_mode:Number — Use one of the NativeCameraExtension.TorchModeconstants

See also

setTranslationPoint()method 
public function setTranslationPoint(_offsetX:Number, _offsetY:Number):void

Allows you to translate the frame. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_offsetX:Number — Horizontal translation offset in pixels
 
_offsetY:Number — Vertical translation offset in pixels

setWhiteBalanceMode()method 
public function setWhiteBalanceMode(_mode:Number):void

Sets the white balance mode. iOS only. Android implementation to come. E-mails us at support [at] diadraw.com with requests to move it up our TODO list.

Parameters

_mode:Number — Use one of the CameraSettings.WhiteBalanceModeconstants

See also

startCameraPreview()method 
public function startCameraPreview(_stage:Stage, _settings:CameraSettings = null):Boolean

Starts the video stream and dispatches NativeCameraDriverEvent.CAMERA_STARTED is dispatched if the camera has started successfully. NativeCameraDriverEvent.FRAME_READY is dispatched, when a frame from the camera is ready to be read; you can obtain the data by reading the event's bitmapData property.

Parameters

_stage:Stage — A reference to the stage.
 
_settings:CameraSettings (default = null) — The settings with which the camera should be run.

Returns
Boolean — true if the settings were accepted, false otherwise. If false is returned, the native code sends a StatusEvent with a message, describing what the problem was: unsupported preset, front camera not supported, etc.

See also

NativeCameraDriverEvent.bitmapData
NativeCameraDriverEvent.CAMERA_STARTED
NativeCameraDriverEvent.FRAME_READY
stopCameraPreview()method 
public function stopCameraPreview():void

Stops the video stream.

swapFrontAndBackCamera()method 
public function swapFrontAndBackCamera():Boolean

Allows you to switch between the front and the back camera at runtime.

Returns
Boolean
Constant Detail
ERROR_COULD_NOT_ACQUIRE_BYTE_ARRAYConstant
public static const ERROR_COULD_NOT_ACQUIRE_BYTE_ARRAY:Number = -10

ERROR_COULD_NOT_RELEASE_BYTE_ARRAYConstant 
public static const ERROR_COULD_NOT_RELEASE_BYTE_ARRAY:Number = -11

ERROR_ERROR_DURING_COPYConstant 
public static const ERROR_ERROR_DURING_COPY:Number = -7

ERROR_EXCEPTION_THROWN_DURING_COPYConstant 
public static const ERROR_EXCEPTION_THROWN_DURING_COPY:Number = -8

ERROR_EXCEPTION_THROWN_DURING_COPY_NO_INFOConstant 
public static const ERROR_EXCEPTION_THROWN_DURING_COPY_NO_INFO:Number = -9

ERROR_NO_DATA_IN_RESERVE_BUFFERConstant 
public static const ERROR_NO_DATA_IN_RESERVE_BUFFER:Number = -4

ERROR_NO_NEW_DATAConstant 
public static const ERROR_NO_NEW_DATA:Number = -5

ERROR_NO_READ_BUFFERConstant 
public static const ERROR_NO_READ_BUFFER:Number = -2

ERROR_NO_RESERVE_BUFFERConstant 
public static const ERROR_NO_RESERVE_BUFFER:Number = -3

ERROR_UNKNOWNConstant 
public static const ERROR_UNKNOWN:Number = -1

ERROR_ZERO_LENGTH_DATAConstant 
public static const ERROR_ZERO_LENGTH_DATA:Number = -6