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 / VideoCameraUI.as
Last active April 28, 2016 23:21
A Basic Starling Camera UI using the distriqt Camera ANE
/**
* __ __ __
* ____/ /_ ____/ /______ _ ___ / /_
* / __ / / ___/ __/ ___/ / __ `/ __/
* / /_/ / (__ ) / / / / / /_/ / /
* \__,_/_/____/_/ /_/ /_/\__, /_/
* / /
* \/
* http://distriqt.com
*
@marchbold
marchbold / distriqt.extension.share.shareFile.as
Last active January 23, 2020 22:48
Using the Share ANE to share a file
if (Share.isSupported)
{
Share.service.addEventListener( ShareEvent.COMPLETE, share_shareHandler );
Share.service.addEventListener( ShareEvent.CANCELLED, share_shareHandler );
Share.service.addEventListener( ShareEvent.FAILED, share_shareHandler );
// Here we have packaged a file "TestDocument.pdf" in an "assets" folder in our AS application project
var path:String = File.applicationDirectory.nativePath + File.separator + "assets" + File.separator + "TestDocument.pdf";
Share.service.shareFile( path, "TestDocument.pdf", "application/pdf" );
@marchbold
marchbold / distriqt.extension.share.share.as
Last active January 23, 2020 22:47
Using the Share ANE to share an image with other applications
[Embed("assets/image.png")]
public var TestImage:Class;
...
if (Share.isSupported)
{
Share.service.addEventListener( ShareEvent.COMPLETE, share_shareHandler );
Share.service.addEventListener( ShareEvent.CANCELLED, share_shareHandler );
Share.service.addEventListener( ShareEvent.FAILED, share_shareHandler );
@marchbold
marchbold / distriqt.extension.inappbilling.applicationReceiptRefresh.as
Last active August 29, 2015 14:23
Refreshing the application receipt in iOS 7+
// Initialise the extension before attempting to refresh the receipt
InAppBilling.service.applicationReceipt.addEventListener( ApplicationReceiptEvent.REFRESH_FAILED, refreshFailedHandler );
InAppBilling.service.applicationReceipt.addEventListener( ApplicationReceiptEvent.REFRESH_SUCCESS, refreshSuccessHandler );
InAppBilling.service.applicationReceipt.refresh();
...
private function refreshSuccessHandler( event:ApplicationReceiptEvent ):void
@marchbold
marchbold / distriqt.extension.application.deviceInfo.as
Last active August 29, 2015 14:23
Retrieving information about the device and operating system
Application.init( APP_KEY );
if (Application.isSupported)
{
//
// PRINT DEVICE INFORMATION
trace( "DEVICE INFO ============================" );
trace( " name: " + Application.service.device.name );
trace( " brand: " + Application.service.device.brand );
trace( " manufacturer: " + Application.service.device.manufacturer );
@marchbold
marchbold / distriqt.extension.paypalsdk.initialisation.as
Created July 9, 2015 06:40
Setting up the PayPal Environment and configuration
public static const PAYPAL_PRODUCTION_CLIENT_ID : String = "APPLICATION_PRODUCTION_CLIENT_ID";
public static const PAYPAL_SANDBOX_CLIENT_ID : String = "APPLICATION_SANDBOX_CLIENT_ID";
try
{
PayPalSDK.init( APP_KEY );
trace( "PayPalSDK Supported: " + PayPalSDK.isSupported );
trace( "PayPalSDK Version: " + PayPalSDK.service.version );
@marchbold
marchbold / distriqt.extension.paypalsdk.singlePayment.as
Last active August 29, 2015 14:24
Making a Single Payment with the PayPal SDK
if (PayPalSDK.isSupported)
{
PayPalSDK.service.addEventListener( PayPalPaymentEvent.COMPLETE, paypal_paymentCompleteHandler );
PayPalSDK.service.addEventListener( PayPalPaymentEvent.CANCELLED, paypal_paymentCancelledHandler );
PayPalSDK.service.addEventListener( PayPalPaymentEvent.ERROR, paypal_paymentErrorHandler );
// Can do this call anywhere before you make a payment,
// but PayPal suggest calling it close to the payment/consent calls
// as connection is 'short lived'
if (PayPalSDK.service.connect( PayPalEnvironment.SANDBOX ))
@marchbold
marchbold / distriqt.extension.paypalsdk.futurePayment.as
Last active August 29, 2015 14:24
Obtaining consent for future payments with the PayPal SDK
if (PayPalSDK.isSupported)
{
PayPalSDK.service.addEventListener( PayPalFuturePaymentEvent.COMPLETE, paypal_futurePaymentCompleteHandler );
PayPalSDK.service.addEventListener( PayPalFuturePaymentEvent.CANCELLED, paypal_futurePaymentCancelledHandler );
PayPalSDK.service.addEventListener( PayPalFuturePaymentEvent.ERROR, paypal_futurePaymentErrorHandler );
if (PayPalSDK.service.connect( PayPalEnvironment.NO_NETWORK ))
{
PayPalSDK.service.obtainConsentForFuturePayment();
}
@marchbold
marchbold / distriqt.extension.paypalsdk.profileSharing.as
Last active August 29, 2015 14:24
Obtain consent for profile sharing with the PayPal SDK
if (PayPalSDK.isSupported)
{
PayPalSDK.service.addEventListener( PayPalProfileSharingEvent.COMPLETE, paypal_profileSharingCompleteHandler );
PayPalSDK.service.addEventListener( PayPalProfileSharingEvent.CANCELLED, paypal_profileSharingCancelledHandler );
PayPalSDK.service.addEventListener( PayPalProfileSharingEvent.ERROR, paypal_profileSharingErrorHandler );
if (PayPalSDK.service.connect( PayPalEnvironment.NO_NETWORK ))
{
var scopes:Vector.<String> = Vector.<String>( [ PayPalAuthScopes.SCOPE_EMAIL, PayPalAuthScopes.SCOPE_ADDRESS ] );
PayPalSDK.service.obtainConsentForProfileSharing( scopes );
@marchbold
marchbold / distriqt.extension.parse.manifestAdditions.xml
Created July 9, 2015 12:27
Manifest additions for the Parse ANE
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />