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.volume.change.as
Last active August 29, 2015 14:26
Listening to volume change events
if (Volume.isSupported)
{
Volume.service.addEventListener( VolumeEvent.CHANGED, volumeChangedHandler );
Volume.service.register();
}
...
private function volumeChangedHandler( event:VolumeEvent ):void
{
@marchbold
marchbold / distriqt.extension.mediaplayer.play.as
Last active October 27, 2018 14:44
Playing a packaged file in an embedded player with the Media Player
var path:String = File.applicationDirectory.nativePath + File.separator + "example.mp4";
MediaPlayer.init( APP_KEY );
if (MediaPlayer.isSupported)
{
MediaPlayer.service.createPlayer( path, 0, 0, 640, 480, false, MediaPlayer.CONTROLS_EMBEDDED );
MediaPlayer.service.play();
}
// com.distriqt.MediaPlayer
@marchbold
marchbold / distriqt.extension.nativewebview.locationChange.as
Last active August 29, 2015 14:25
Handling and intercepting location change events in a WebView
// Here we assume you have previously initialised the extension
var webView:WebView = NativeWebView.service.createWebView( new Rectangle( 0, 0, 400, 600 ) ) ;
webView.addEventListener( NativeWebViewEvent.LOCATION_CHANGING, webView_locationChangingHandler );
webView.addEventListener( NativeWebViewEvent.LOCATION_CHANGE, webView_locationChangeHandler );
webView.loadURL( "http://airnativeextensions.com" );
...
@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.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.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
@marchbold
marchbold / distriqt.extension.adverts.example.as
Last active April 23, 2018 06:31
This very simple example demonstrates initialising the extension and the advertising platform and then displaying an advert aligned to the bottom centre.
if (Adverts.isSupported)
{
Adverts.service.initialisePlatform( AdvertPlatform.PLATFORM_ADMOB );
var adView:AdView = Adverts.service.createAdView();
adView.setAdSize( AdSize.SMART_BANNER );
adView.setAdUnitId( AD_UNIT_ID );
adView.setViewParams( new AdViewParamsBuilder()
.setVerticalAlign( AdViewParams.ALIGN_BOTTOM )
.setHorizontalAlign( AdViewParams.ALIGN_CENTER )
@marchbold
marchbold / distriqt.extension.networkinfo.example.as
Last active January 15, 2016 21:35
Determine the network availability of your application, whether it has an internet access and whether it is a cellular (WWAN) or WiFi connection
NetworkInfo.init( "" );
NetworkInfo.networkInfo.addEventListener(
NetworkInfoEvent.CHANGE,
networkChangeHandler
);
...
@marchbold
marchbold / distriqt.extension.notifications.example.as
Last active August 29, 2015 13:57
Simple example of displaying a local notification.
try
{
Notifications.init( APP_KEY );
if (Notifications.isSupported)
{
Notifications.service.addEventListener( NotificationEvent.NOTIFICATION_SELECTED, notifications_notificationSelectedHandler, false, 0, true );
//
// This will trigger the start up notification if the application was started from a delayed notification
// Also this will perform the required registration for notifications permission on iOS 8+