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.googleanalytics.manifestAdditions.xml
Last active November 25, 2015 23:55
Manifest Additions for the Google Analytics ANE
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- Optional permission for reliable local dispatching on non-Google Play devices -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
@marchbold
marchbold / distriqt.extension.googleanalytics.createTracker.as
Created November 18, 2015 02:05
Creating / retrieving a Tracker and setting a value using the GoogleAnalytics ANE
var tracker:Tracker = GoogleAnalytics.service.getTracker( "YOUR_TRACKING_ID" );
// Set a value that will be sent with every message
tracker.setValue( "&uid", "userIdString" );
// com.distriqt.GoogleAnalytics
@marchbold
marchbold / distriqt.extension.googleanalytics.sendScreenView.as
Created November 18, 2015 02:09
Sending a screen view using the GoogleAnalyitcs ANE
var tracker:Tracker = GoogleAnalytics.service.getTracker( "YOUR_TRACKING_ID" );
// Sets the screen name. This will be sent with any subsequent events / views on this tracker
tracker.setScreenName( "currentScreenName" );
tracker.send( new ScreenViewBuilder().build() );
// com.distriqt.GoogleAnalytics
@marchbold
marchbold / distriqt.extension.googleanalytics.sendEvent.as
Last active November 18, 2015 02:28
Sending an Event using the GoogleAnalytics ANE
var tracker:Tracker = GoogleAnalytics.service.getTracker( "YOUR_TRACKING_ID" );
tracker.send(
new EventBuilder()
.setCategory( "user" )
.setAction( "signIn" )
.setValue( 123 )
.build() );
// com.distriqt.GoogleAnalytics
@marchbold
marchbold / distriqt.extension.googleanalytics.ecommerce.as
Last active November 18, 2015 02:40
Sending an Ecommerce hit with the GoogleAnalytics ANE
var tracker:Tracker = GoogleAnalytics.service.getTracker( "YOUR_TRACKING_ID" );
// Send the overview of the transaction
tracker.send(
new TransactionBuilder()
.setTransactionId(transactionId)
.setAffiliation("internal")
.setRevenue(12.22)
.setTax(0)
.setShipping(0)
package
{
import flash.display.MovieClip;
import com.distriqt.extension.gyroscope.Gyroscope;
import com.distriqt.extension.gyroscope.events.GyroscopeEvent;
public class Main extends MovieClip
{
public static const APP_KEY: String = "APPLICATION_KEY";
CameraRollExtended.service.addEventListener( AuthorisationEvent.CHANGED, authorisationChangedHandler );
switch (CameraRollExtended.service.authorisationStatus())
{
case AuthorisationStatus.SHOULD_EXPLAIN:
case AuthorisationStatus.NOT_DETERMINED:
// REQUEST ACCESS: This will display the permission dialog
CameraRollExtended.service.requestAccess();
return;
case AuthorisationStatus.DENIED:
@marchbold
marchbold / distriqt.extension.camerarollextended.browseForAsset.as
Last active December 8, 2015 12:22
Selecting an image using the Camera Roll Extended ANE
CameraRollExtended.init( APP_KEY );
if (CameraRollExtended.isSupported)
{
CameraRollExtended.service.addEventListener( CameraRollExtendedEvent.CANCEL, cancelHandler );
CameraRollExtended.service.addEventListener( CameraRollExtendedEvent.SELECT, selectHandler );
var options:CameraRollExtendedBrowseOptions = new CameraRollExtendedBrowseOptions();
options.maximumCount = 5;
options.type = Asset.IMAGE;
@marchbold
marchbold / distriqt.extension.camerarollextended.loadAsset.as
Created December 8, 2015 22:34
Loading an Asset using the Camera Roll Extended ANE
var asset:Asset = ... ; // Asset retrieved via user selection (browseForAsset)
if (asset.type == Asset.IMAGE)
{
CameraRollExtended.service.addEventListener( CameraRollExtendedEvent.ASSET_LOADED, assetLoadedHandler );
CameraRollExtended.service.loadAssetByURL( asset.url, AssetRepresentation.THUMBNAIL );
}
...
@marchbold
marchbold / distriqt.extension.camerarollextended.getFileForAsset.as
Created December 8, 2015 23:13
Retrieving a File reference to an Asset using the Camera Roll Extended ANE
var asset:Asset = ... ; // Asset retrieved via user selection (browseForAsset)
var f:File = CameraRollExtended.service.getFileForAsset( asset );
if (f != null && f.exists)
{
trace( "ASSET FILE: "+f.nativePath );
// Use File as you require
}
// com.distriqt.CameraRollExtended