Skip to content

Instantly share code, notes, and snippets.

View marchbold's full-sized avatar
🚲
making stuff...

Michael marchbold

🚲
making stuff...
View GitHub Profile
@marchbold
marchbold / CameraPreview.as
Last active December 4, 2017 17:30
Camera v4 ANE Preview Frame Example
/**
* __ __ __
* ____/ /_ ____/ /______ _ ___ / /_
* / __ / / ___/ __/ ___/ / __ `/ __/
* / /_/ / (__ ) / / / / / /_/ / /
* \__,_/_/____/_/ /_/ /_/\__, /_/
* / /
* \/
* http://distriqt.com
*
@marchbold
marchbold / distriqt.extension.ocr.recognise.as
Created December 16, 2016 11:42
Simple optical character recognition with the OCR ANE
OCR.service.addEventListener( OCREvent.RECOGNISE, ocr_recogniseHandler );
OCR.service.addEventListener( OCREvent.RECOGNISE_ERROR, ocr_recogniseErrorHandler );
var options:OCROptions = new OCROptions();
options.language = "eng";
options.whitelist = "0123456789.,€$";
var success:Boolean = OCR.service.recognise( image.bitmapData, options );
...
@marchbold
marchbold / distriqt.extension.localauth.authenticateWithFingerprint.as
Created December 16, 2016 09:53
Local Authentication with a user's fingerprint (TouchID) using the LocalAuth ANE
if (LocalAuth.service.canAuthenticateWithFingerprint())
{
// Fingerprint authentication is available
LocalAuth.service.addEventListener( LocalAuthEvent.AUTH_SUCCESS, authSuccessHandler );
LocalAuth.service.addEventListener( LocalAuthEvent.AUTH_FAILED, authFailedHandler );
LocalAuth.service.authenticateWithFingerprint( "Unlock access to locked feature" );
}
@marchbold
marchbold / distriqt.extension.nativemaps.createMap.as
Last active October 7, 2016 04:51
Create a native map using the NativeMaps ANE
var viewport:Rectangle = new Rectangle( 0, 0, 500, 800 );
NativeMaps.service.addEventListener( NativeMapEvent.MAP_CREATED, mapCreatedHandler );
var success:Boolean = NativeMaps.service.createMap( viewport.width, viewport.height, viewport.x, viewport.y, MapType.MAP_TYPE_HYBRID );
if (success)
{
trace( "Map creation started successfully" );
}
else
@marchbold
marchbold / TestImage.as
Created September 18, 2016 00:11
Example of saving a screen shot to the camera roll
package
{
import com.distriqt.extension.image.Image;
import com.distriqt.extension.image.ImageFormat;
import com.distriqt.extension.image.events.ImageDataEvent;
import com.distriqt.extension.image.events.ImageEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
@marchbold
marchbold / distriqt.extension.cameraui.manifestadditions.xml
Last active November 1, 2016 07:34
Manifest Additions for the CameraUI ANE
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- optional if your application REQUIRES the camera -->
<uses-feature android:name="android.hardware.camera" android:required="true" />
<application android:hardwareAccelerated="true">
@marchbold
marchbold / distriqt.extension.cameraui.launch.video.as
Created September 8, 2016 06:42
Capture a Video using the Camera UI
CameraUI.service.addEventListener( CameraUIEvent.COMPLETE, cameraUI_completeHandler );
CameraUI.service.addEventListener( CameraUIEvent.CANCEL, cameraUI_cancelHandler );
var options:CameraUIOptions = new CameraUIOptions();
options.videoQuality = QualityType.TYPE_HIGH;
CameraUI.service.launch( MediaType.VIDEO, options );
...
@marchbold
marchbold / distriqt.extension.cameraui.launch.as
Created September 8, 2016 06:34
Capture an Image using the CameraUI
CameraUI.service.addEventListener( CameraUIEvent.COMPLETE, cameraUI_completeHandler );
CameraUI.service.addEventListener( CameraUIEvent.CANCEL, cameraUI_cancelHandler );
CameraUI.service.launch( MediaType.IMAGE );
...
private function cameraUI_completeHandler( event:CameraUIEvent ):void
{
// Here you can use the event.path to access the media file as you require
@marchbold
marchbold / distriqt.extension.webp.loader.as
Last active September 7, 2016 05:52
Loading a WebP file Asynchronously using the WebP ANE
var loader:WebPLoader = WebP.service.createLoader();
loader.addEventListener( WebPLoaderEvent.COMPLETE, loader_completeHandler );
loader.addEventListener( WebPErrorEvent.ERROR, loader_errorHandler );
var success:Boolean = loader.load( file.url );
trace( "loader.load( " + file.url + " ) = " + success );
...
@marchbold
marchbold / distriqt.extension.cloudstorage.entitlements.xml
Created August 17, 2016 05:59
iCloud entitlements for using document storage in iCloud containers
<iPhone>
<InfoAdditions><![CDATA[
<key>UIDeviceFamily</key>
<array>
<string>1</string>
<string>2</string>
</array>
]]></InfoAdditions>
<requestedDisplayResolution>high</requestedDisplayResolution>
<Entitlements>