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.gameservices.signin.as
Created February 5, 2015 01:53
Demonstrates the basic sign in functionality for the Game Services ANE.
// Initialisation etc goes here but we add the following event listeners
GameServices.service.addEventListener( GameServicesEvent.SIGN_IN_SUCCESS, signInSuccessHandler );
GameServices.service.addEventListener( GameServicesEvent.SIGN_IN_FAILED, signInFailedHandler );
GameServices.service.addEventListener( GameServicesEvent.SIGN_OUT_SUCCESS, signOutSuccessHandler );
...
public function signIn():void
@marchbold
marchbold / distriqt.extension.gameservices.loadLeaderboards.as
Last active August 12, 2016 11:16
Simple example showing the loading and handling of leaderboard data
// Initialisation code goes here
// Your player must be signed in for leaderboard functionality
GameServices.service.leaderboards.addEventListener( LeaderboardEvent.LEADERBOARDS_LOADED, leaderboardsLoadedHandler );
GameServices.service.leaderboards.addEventListener( LeaderboardEvent.LEADERBOARDS_ERROR, leaderboardsErrorHandler );
GameServices.service.leaderboards.addEventListener( LeaderboardEvent.TOPSCORES_LOADED, topScoresLoadedHandler );
GameServices.service.leaderboards.addEventListener( LeaderboardEvent.TOPSCORES_ERROR, topScoresErrorHandler );
if (GameServices.service.isSignedIn() && GameServices.service.leaderboards.isSupported)
{
GameServices.service.leaderboards.loadLeaderboards( true );
@marchbold
marchbold / distriqt.extension.gameservices.achievements.as
Created February 5, 2015 02:07
Achievements. A simple example showing the loading of the available achievements for the currently signed in player.
// Initialisation code and sign in code
// You must be signed in for achievements to work
GameServices.service.achievements.addEventListener( AchievementEvent.ACHIEVEMENTS_LOADED, achievementsLoadedHandler );
GameServices.service.achievements.addEventListener( AchievementEvent.ACHIEVEMENTS_ERROR, achievementsErrorHandler );
if (GameServices.service.isSignedIn() && GameServices.service.achievements.isSupported)
{
GameServices.service.achievements.loadAchievements( true );
}
...
@marchbold
marchbold / distriqt.extension.pushnotifications.registration.as
Last active March 18, 2016 07:26
Registering for notifications using the Push Notifications ANE
PushNotifications.init( APP_KEY );
if (PushNotifications.isSupported)
{
PushNotifications.service.addEventListener( RegistrationEvent.REGISTERING, registeringHandler );
PushNotifications.service.addEventListener( RegistrationEvent.REGISTER_SUCCESS, registerSuccessHandler );
PushNotifications.service.addEventListener( RegistrationEvent.REGISTER_FAILED, registerFailedHandler );
PushNotifications.service.addEventListener( RegistrationEvent.ERROR, errorHandler );
PushNotifications.service.register();
}
@marchbold
marchbold / distriqt.extensions.contacts.showContactPicker.as
Created February 12, 2015 12:57
Display a native picker dialog for user contact selection
// Before here we have already requested access and performed the initialisation (as above)
Contacts.service.addEventListener( ContactsEvent.CONTACT_SELECTED, contact_selectedHandler );
Contacts.service.addEventListener( ContactsEvent.CONTACTPICKER_CANCEL, contacts_contactPickerCancelHandler );
if (!Contacts.service.showContactPicker())
{
trace( "Access to contacts list denied by user" );
}
@marchbold
marchbold / distriqt.extensions.contacts.permissions.as
Created February 12, 2015 12:59
Check for permissions to access the user contact list
if (Contacts.isSupported)
{
Contacts.service.addEventListener( ContactsEvent.ACCESS_GRANTED, contacts_accessGrantedHandler );
Contacts.service.addEventListener( ContactsEvent.ACCESS_DENIED, contacts_accessDeniedHandler );
// Check if we have access to the user's contacts
if (!Contacts.service.hasAccess())
{
// If not, lets attempt to get access
if (Contacts.service.requestAccess())
@marchbold
marchbold / distriqt.extensions.flurry.logEvent.as
Created March 19, 2015 03:04
Flurry example to initialise, start a session and log an event
try
{
Flurry.init( "APPLICATION_KEY" );
trace( "Flurry Supported: " + Flurry.isSupported );
if (Flurry.isSupported)
{
trace( "Flurry Version: " + Flurry.service.version );
trace( "Flurry Agent Version: " + Flurry.service.analytics.getFlurryAgentVersion() );
@marchbold
marchbold / distriqt.extension.application.deviceInfo.as
Last active August 29, 2015 14:17
Device Information using the Application ANE
try
{
Application.init( APPLICATION_KEY );
if (Application.isSupported)
{
trace( "DEVICE INFO ============================" );
trace( " name: " + Application.service.device.name );
trace( " brand: " + Application.service.device.brand );
trace( " manufacturer: " + Application.service.device.manufacturer );
trace( " device: " + Application.service.device.device );
@marchbold
marchbold / distriqt.extension.application.deactivation.as
Last active August 29, 2015 14:17
Determine if the user deactivated your app via the home or lock button
Application.init( APPLICATION_KEY );
if (Application.isSupported)
{
Application.service.addEventListener( ApplicationStateEvent.DEACTIVATE, application_deactivateHandler );
}
function application_deactivateHandler( event:ApplicationStateEvent ):void
{
switch (event.code)
{
@marchbold
marchbold / distriqt.extension.application.displayMode.as
Last active October 22, 2016 01:23
Setting the Application Display Mode
Application.init( APPLICATION_KEY );
if (Application.isSupported)
{
Application.service.addEventListener( ApplicationEvent.UI_NAVIGATION_CHANGED, uiNavigationChangedHandler );
// Hide the on screen navigation controls
Application.service.setDisplayMode( ApplicationDisplayModes.UI_NAVIGATION_HIDE );
}
function uiNavigationChangedHandler( event:ApplicationEvent ):void
{