Packagecom.distriqt.extension.scanner
Classpublic final class Scanner
InheritanceScanner Inheritance flash.events.EventDispatcher

This class represents the scanner extension.

The scanner creates an interface using the camera to scan for codes such as QR Codes, bar codes and other such encoded information. It supports many popular symbologies (types of bar codes) including EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code. However the particular support will be determined by the underlying algorithm in use.

The extension currently supports the following algorithms for code detection:

There are two main modes of operation, continuous and single result. Continuous mode is the default mode. In this mode the scanner will continually scan for symbols and return events whenever a symbol is found. The single result mode will close the scanner as soon as one symbol is found and returned. Single result mode is enabled by setting the singleResult option to be true as below:

     var options:ScannerOptions = new ScannerOptions();
     options.singleResult = true;
     
     Scanner.service.startScan( options );
     

The scanner interface contains two optional areas, with text labels and buttons. The text in these areas are controlled by strings in the options class passed to the startScan function.

Android

An Android application will require the following manifest additions to the application descriptor.

<android>
    <manifestAdditions><![CDATA[
        <manifest android:installLocation="auto">
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.CAMERA"/>
            <uses-feature android:name="android.hardware.camera" />
            
            <application>
                <activity android:screenOrientation="portrait" android:name="com.distriqt.extension.scanner.zbar.ZBarScannerActivity" />
            </application>
            
        </manifest>
    ]]></manifestAdditions>
</android>
     

View the examples



Public Properties
 PropertyDefined By
  implementation : String
[read-only] The implementation currently in use.
Scanner
  isSupported : Boolean
[static] [read-only] Whether the current device supports the extensions functionality
Scanner
  nativeVersion : String
[read-only] The native version string of the native extension.
Scanner
  service : Scanner
[static] [read-only] The singleton instance of the Scanner class.
Scanner
  version : String
[read-only] The version of this extension.
Scanner
Public Methods
 MethodDefined By
  
Constructor You should not call this directly, but instead use the singleton access
Scanner
  
Retrieves the current authorisation status of this application.
Scanner
  
dispose():void
Disposes the extension and releases any allocated resources.
Scanner
  
Retrieves information about the scanning algorithm currently being used in the native code.
Scanner
  
hasAccess():Boolean
Helper method to determine if the current application has access to the device camera
Scanner
  
init(key:String):void
Deprecated: You no longer need to use an application key
[static] Initialises the extension class for use with the provided key.
Scanner
  
isScanning():Boolean
Determines if the scanner is currently in operation and displayed to the user.
Scanner
  
requestAccess():Boolean
Performs a simple operation to display the permission dialog.
Scanner
  
scanBitmap(bitmap:BitmapData):Array
Scans the supplied bitmap data for any symbols.
Scanner
  
Sets the scanner options to use for any scanBitmap calls.
Scanner
  
setScanViewport(frame:Rectangle):Boolean
Updates the scanner viewport to the specified area.
Scanner
  
startScanActivity(uiOptions:ActivityOptions = null, scannerOptions:ScannerOptions = null, cameraOptions:CameraOptions = null):Boolean
Starts the fullscreen scanning activity with options specified.
Scanner
  
startScanInViewport(viewportOptions:ViewportOptions, scannerOptions:ScannerOptions = null, cameraOptions:CameraOptions = null):Boolean
Starts a scanner process contained within the specified viewport.
Scanner
  
stopScan():Boolean
Stops the current scan process (if running).
Scanner
Public Constants
 ConstantDefined By
  EXT_CONTEXT_ID : String = com.distriqt.Scanner
[static]
Scanner
  VERSION : String = 5.1.0
[static]
Scanner
Property Detail
implementationproperty
implementation:String  [read-only]

The implementation currently in use. This should be one of the following depending on the platform in use and the functionality supported by this extension:


Implementation
    public function get implementation():String
isSupportedproperty 
isSupported:Boolean  [read-only]

Whether the current device supports the extensions functionality


Implementation
    public static function get isSupported():Boolean
nativeVersionproperty 
nativeVersion:String  [read-only]

The native version string of the native extension.


Implementation
    public function get nativeVersion():String
serviceproperty 
service:Scanner  [read-only]

The singleton instance of the Scanner class.


Implementation
    public static function get service():Scanner

Throws
Error — If there was a problem creating or accessing the extension, or if the developer key is invalid
versionproperty 
version:String  [read-only]

The version of this extension.

This should be of the format, MAJOR.MINOR.BUILD


Implementation
    public function get version():String
Constructor Detail
Scanner()Constructor
public function Scanner()

Constructor You should not call this directly, but instead use the singleton access

Method Detail
authorisationStatus()method
public function authorisationStatus():String

Retrieves the current authorisation status of this application.

There are several possible values as defined in the AuthorisationStatus class.

Returns
String — The AuthorisationStatus string

See also

com.distriqt.extension.camera.AuthorisationStatus
dispose()method 
public function dispose():void

Disposes the extension and releases any allocated resources. Once this function has been called, a call to init is neccesary again before any of the extensions functionality will work.

getScannerInfo()method 
public function getScannerInfo():ScannerInfo

Retrieves information about the scanning algorithm currently being used in the native code.

Returns
ScannerInfo — A scanner information object with details about the algorithm
hasAccess()method 
public function hasAccess():Boolean

Helper method to determine if the current application has access to the device camera

Returns
Boolean
init()method 
public static function init(key:String):void
Deprecated: You no longer need to use an application key

Initialises the extension class for use with the provided key.

Parameters

key:String


Throws
Error — If there was a problem creating or accessing the extension, or if the key is invalid
isScanning()method 
public function isScanning():Boolean

Determines if the scanner is currently in operation and displayed to the user.

Returns
Boolean — true if the scanner is in operation and false otherwise
requestAccess()method 
public function requestAccess():Boolean

Performs a simple operation to display the permission dialog.

Note this will only be shown if the authorisation status is currently NOT_DETERMINED

You do not need to call this function, it just allows you to control when the permission dialog is presented. If you don't call this function then the permission dialog will be displayed just before your first access camera.

Returns
Boolean
scanBitmap()method 
public function scanBitmap(bitmap:BitmapData):Array

Scans the supplied bitmap data for any symbols. The resulting array will contain ScanResult objects representing any symbols found in the image.

Parameters

bitmap:BitmapData — The bitmap data to scan

Returns
Array — An array of ScanResult objects. May be empty if none were found.
setScanBitmapOptions()method 
public function setScanBitmapOptions(options:ScannerOptions):void

Sets the scanner options to use for any scanBitmap calls.

Parameters

options:ScannerOptions

setScanViewport()method 
public function setScanViewport(frame:Rectangle):Boolean

Updates the scanner viewport to the specified area.

Parameters

frame:Rectangle — The new viewport rectangle to use

Returns
Booleantrue if successful and false if the scanner was not running in viewport mode
startScanActivity()method 
public function startScanActivity(uiOptions:ActivityOptions = null, scannerOptions:ScannerOptions = null, cameraOptions:CameraOptions = null):Boolean

Starts the fullscreen scanning activity with options specified.

Parameters

uiOptions:ActivityOptions (default = null) — Options for the UI elements of the scanner
 
scannerOptions:ScannerOptions (default = null) — The options to start the scanner with
 
cameraOptions:CameraOptions (default = null) — Options for the camera (device, etc)

Returns
Booleantrue if the scanner was started successfully and false otherwise
startScanInViewport()method 
public function startScanInViewport(viewportOptions:ViewportOptions, scannerOptions:ScannerOptions = null, cameraOptions:CameraOptions = null):Boolean

Starts a scanner process contained within the specified viewport. The viewport will contain a camera preview overlay

Parameters

viewportOptions:ViewportOptions — Options describing the viewport for the scanner
 
scannerOptions:ScannerOptions (default = null) — The options to start the scanner with
 
cameraOptions:CameraOptions (default = null) — Options for the camera (device, etc)

Returns
Booleantrue if the scanner was started successfully and false otherwise
stopScan()method 
public function stopScan():Boolean

Stops the current scan process (if running). If the current process is a fullscreen activity then it is closed and focus returned to the application. If the current process is a viewport scan then the view is removed and the scan process stopped.

Returns
Booleantrue if the scanner was running and stopped successfully and false if it wasn't running.
Constant Detail
EXT_CONTEXT_IDConstant
public static const EXT_CONTEXT_ID:String = com.distriqt.Scanner

VERSIONConstant 
public static const VERSION:String = 5.1.0

Examples

The following example shows the basic usage of the extension, creating a scanning interface and listening for detected QR codes. It limits the scan to the first found code and will close after a code is found.

     Scanner.init( DEV_KEY );
     
     if (Scanner.isSupported)
     {
         Scanner.service.addEventListener( ScannerEvent.CODE_FOUND, scanner_codeFoundHandler, false, 0, true );
     
         var options:ScannerOptions = new ScannerOptions();
         options.symbologies = [ Symbology.QRCODE ];
         options.singleResult = true;
     
         Scanner.service.startScan( options );
     }                
     
     ...
     
     private function scanner_codeFoundHandler( event:ScannerEvent ):void
     {
         trace( "code found: " + event.data );
     }