Skip to content

Instantly share code, notes, and snippets.

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

Michael marchbold

🚲
making stuff...
View GitHub Profile
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-games</artifactId>
<version>9.4.0</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-base</artifactId>
@marchbold
marchbold / distriqt.extension.gameservices.enableSavedGames.as
Created August 10, 2016 00:07
Enabling Saved Games in your services configuration using the GameServices ANE
var service:Service = new Service( Service.GOOGLE_PLAY_GAME_SERVICES );
service.enableSavedGames = true;
GameServices.service.initialiseService( service );
// com.distriqt.GameServices
@marchbold
marchbold / distriqt.extension.expansionfiles.unmount.as
Created July 31, 2016 02:35
Unmounting an OBB file using the ExpansionFiles ANE
var obbFile:ExpansionFile = new ExpansionFile( ExpansionFile.MAIN, 1001003, 93147195 );
if (ExpansionFiles.service.obbUtils.isMounted( obbFile ))
{
ExpansionFiles.service.obbUtils.unmount( obbFile );
}
// com.distriqt.ExpansionFiles
@marchbold
marchbold / distriqt.extension.expansionfiles.readMountedFile.as
Last active July 31, 2016 02:29
Read files from a mounted OBB file using the ExpansionFiles ANE
var obbFile:ExpansionFile = new ExpansionFile( ExpansionFile.MAIN, 1001003, 93147195 );
if (ExpansionFiles.service.obbUtils.isMounted( obbFile ))
{
var path:String = ExpansionFiles.service.obbUtils.getMountedPath( obbFile );
var file:File = new File( path + "/images/image.jpg" );
// You can use normal file operations
trace( file.url );
trace( "exists="+file.exists );
@marchbold
marchbold / distriqt.extension.expansionfiles.mount.as
Last active July 31, 2016 02:23
Mount an OBB expansion file using the ExpansionFiles ANE
var obbFile:ExpansionFile = new ExpansionFile( ExpansionFile.MAIN, 1001003, 93147195 );
if (ExpansionFiles.service.expansionFilesDelivered())
{
ExpansionFiles.service.obbUtils.addEventListener( OBBUtilsEvent.STATE_CHANGED, obbUtils_stateChangedHandler );
var success:Boolean = ExpansionFiles.service.obbUtils.mount( obbFile );
}
...
@marchbold
marchbold / distriqt.extension.cloudstorage.documentstore.loadDocument.as
Created July 29, 2016 01:10
Load a document using the Cloud Storage ANE
CloudStorage.service.documentStore.addEventListener( DocumentEvent.LOAD_COMPLETE, loadCompleteHandler );
CloudStorage.service.documentStore.addEventListener( DocumentEvent.LOAD_ERROR, loadErrorHandler );
var success:Boolean = CloudStorage.service.documentStore.loadDocument( "uniqueFilename.txt" );
...
private function loadCompleteHandler( event:DocumentEvent ):void
{
trace( "document load complete" );
@marchbold
marchbold / distriqt.extension.cloudstorage.documentstore.as
Last active July 29, 2016 01:12
Create a document using the Cloud Storage ANE
var document:Document = new Document();
document.filename = "uniqueFilename.txt"; // Must be unique in the container
document.data = new ByteArray();
document.data.writeUTFBytes( "TEST SOME STRING WRITING" ); // Some test data
CloudStorage.service.documentStore.addEventListener( DocumentEvent.SAVE_COMPLETE, createCompleteHandler );
CloudStorage.service.documentStore.addEventListener( DocumentEvent.SAVE_ERROR, createErrorHandler );
CloudStorage.service.documentStore.saveDocument( document );
@marchbold
marchbold / distriqt.extension.cloudstorage.documentstore.listDocuments.as
Created July 29, 2016 01:03
List documents available using the Cloud Storage ANE
if (CloudStorage.service.documentStore.isAvailable)
{
var documents:Vector.<Document> = CloudStorage.service.documentStore.listDocuments();
for each (var document:Document in documents)
{
trace( "document: "+document.filename +" ["+document.url+"]" );
}
}
@marchbold
marchbold / distriqt.extension.cloudstorage.documentstore.isAvailable.as
Created July 29, 2016 00:59
Check cloud document storage is available on the current device using the Cloud Storage ANE
if (CloudStorage.service.documentStore.isAvailable)
{
// Cloud document storage is available
}
else
{
// Handle this situation appropriately
}
// com.distriqt.CloudStorage
@marchbold
marchbold / distriqt.extension.cloudstorage.documentstore.update.as
Created July 29, 2016 00:54
Manually forcing a container update using the Cloud Storage ANE
CloudStorage.service.documentStore.addEventListener( DocumentStoreEvent.UPDATE_START, updateStartHandler );
CloudStorage.service.documentStore.addEventListener( DocumentStoreEvent.UPDATE_END, updateEndHandler );
CloudStorage.service.documentStore.update();
...
private function updateStartHandler( event:DocumentStoreEvent ):void
{
trace( "update started" );