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 / distriqt.extension.application.setStatusBarStyle.as
Last active August 29, 2015 14:17
Control the iOS Status Bar Style
Application.init( APPLICATION_KEY );
if (Application.isSupported)
{
Application.service.setStatusBarStyle( IOSStatusBarStyles.IOS_STATUS_BAR_LIGHT );
Application.service.setStatusBarHidden( false );
}
// com.distriqt.Application
Application.init( APPLICATION_KEY );
if (Application.isSupported)
{
var uniqueId:String = Application.service.device.uniqueId();
}
// com.distriqt.Application
try
{
InAppBilling.init( APPLICATION_KEY );
if (InAppBilling.isSupported)
{
trace( "InAppBilling.service.version = " + InAppBilling.service.version );
// Functionality here
}
else
@marchbold
marchbold / distriqt.extension.inappbilling.servicesSetup.as
Last active August 29, 2015 14:19
Setting up an InAppBilling Service
try
{
InAppBilling.init( APPLICATION_KEY );
if (InAppBilling.isSupported)
{
trace( "InAppBilling.service.version = " + InAppBilling.service.version );
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_SUCCESS, setup_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_FAILURE, setup_failureHandler );
private var _products : Array;
private var _productIds : Array = [ "com.distriqt.testProduct1", "com.distriqt.testProduct2" ];
InAppBilling.init( APPLICATION_KEY );
if (InAppBilling.isSupported)
{
trace( "InAppBilling.service.version = " + InAppBilling.service.version );
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_SUCCESS, setup_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_FAILURE, setup_failureHandler );
// The service must be setup and a list of products retrieved.
// Make sure you have the following listeners
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASES_UPDATED, purchases_updatedHandler );
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_FAILED, purchase_failedHandler );
var request:PurchaseRequest = new PurchaseRequest();
request.productId = productId;
request.quantity = 1;
var success:Boolean = InAppBilling.service.makePurchase( request );
// The service must be setup and a list of products retrieved.
// Make sure you have the following listeners
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_RESTORED, purchase_restoredHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.RESTORE_PURCHASES_SUCCESS, restorePurchases_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.RESTORE_PURCHASES_FAILED, restorePurchases_failedHandler );
InAppBilling.service.restorePurchases();
...
// The service must be setup and a list of products retrieved.
// Make sure you have the following listeners
InAppBilling.service.addEventListener( InAppBillingEvent.CONSUME_SUCCESS, consumePurchase_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.CONSUME_FAILED, consumePurchase_failedHandler );
InAppBilling.service.consumePurchase( new PurchaseRequest( productId ) );
...
private function consumePurchase_successHandler( event:InAppBillingEvent ):void
@marchbold
marchbold / distriqt.extension.webp.loadWebPBitmapData.as
Created May 12, 2015 07:42
Loading a WebP file to a BitmapData
try
{
WebP.init( APPLICATION_KEY );
if (WebP.isSupported)
{
// Find a file packaged with the application
var file:File = File.applicationDirectory.resolvePath( "image.webp" );
var bd:BitmapData = WebP.service.loadWebPBitmapData( path.url );
}
}
try
{
WebP.init( APPLICATION_KEY );
if (WebP.isSupported)
{
// For this example load data from a file into a ByteArray
var file:File = File.applicationDirectory.resolvePath( "image.webp" );
var fs:FileStream = new FileStream();
fs.open( file, FileMode.READ );
var data:ByteArray = new ByteArray();