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 / listFiles.as
Created October 23, 2018 08:36
List files in File.applicationStorage
function listFiles( file:File, prefix:String="" ):void
{
if (file.isDirectory)
{
var files:Array = file.getDirectoryListing();
for each (var f:File in files)
{
listFiles( f, prefix + file.name + "/" );
}
}
@marchbold
marchbold / distriqt.extension.application.yearClass.as
Created August 12, 2018 05:36
Performance tuning using the Year Class from the Application ANE
var year:int = Application.service.device.yearClass;
if (year >= 2013)
{
// Do advanced animation
}
else if (year > 2010)
{
// Do simple animation
}
else
@marchbold
marchbold / distriqt.extension.vibration.feedback.as
Created July 30, 2018 05:01
Simple haptic feedback example using the distriqt Vibration ANE
var keyPressGenerator:FeedbackGenerator = Vibration.service.createFeedbackGenerator( FeedbackGeneratorType.KEY );
keyPressGenerator.performFeedback();
// com.distriqt.Vibration
@marchbold
marchbold / distriqt.extension.vibration.vibrate.as
Last active July 30, 2018 05:01
Simple vibration example
Vibration.service.vibrate( 500 );
// com.distriqt.Vibration
@marchbold
marchbold / distriqt.extension.adverts.rewarded.reward.as
Created April 23, 2018 06:06
Rewarding your user after a Rewarded Video Ad using the Adverts ANE
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.REWARD, rewardHandler );
function rewardHandler( event:RewardedVideoAdEvent ):void
{
// Here you should reward your user
// event.rewardAmount contains the amount that should be awarded to your user
// event.rewardType contains the type of this reward
}
@marchbold
marchbold / distriqt.extension.adverts.rewarded.show.as
Created April 23, 2018 06:01
Show a Rewarded Video Ad using the Adverts ANE
if (rewardedVideoAd.isLoaded())
{
rewardedVideoAd.show();
}
// com.distriqt.Adverts
var rewardedVideoAd : RewardedVideoAd = Adverts.service.rewardedVideoAds.createRewardedVideoAd();
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.LOADED, loadedHandler );
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.ERROR, errorHandler );
rewardedVideoAd.load(
adUnitId,
new AdRequestBuilder().build()
);
@marchbold
marchbold / distriqt.extension.adverts.rewarded.create.as
Created April 23, 2018 05:48
Create a Rewarded Video Ad using the Adverts ANE
var rewardedVideoAd : RewardedVideoAd = Adverts.service.rewardedVideoAds.createRewardedVideoAd();
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.LOADED, loadedHandler );
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.ERROR, errorHandler );
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.OPENED, openedHandler );
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.VIDEO_STARTED, videoStartedHandler );
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.LEFT_APPLICATION, leftApplicationHandler );
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.CLOSED, closedHandler );
rewardedVideoAd.addEventListener( RewardedVideoAdEvent.REWARD, rewardHandler );
@marchbold
marchbold / distriqt.extension.nfc.foreground.as
Created March 22, 2018 04:33
Register for foreground dispatch using the NFC ANE
if (NFC.isSupported)
{
NFC.service.registerForegroundDispatch();
}
// com.distriqt.NFC
@marchbold
marchbold / distriqt.extension.dialog.popover.as
Last active August 30, 2017 06:57
Popover Dialog using the Dialog ANE
Dialog.service.addEventListener( PopoverEvent.POPOVER_CLOSED, popover_closedHandler, false, 0, true );
Dialog.service.addEventListener( PopoverEvent.POPOVER_CHANGE, popover_changeHandler, false, 0, true );
var options:PopoverOptions = new PopoverOptions();
options.position = new Rectangle( 50, 250, 150, 50 );
options.size = new Rectangle( 0, 0, 300, 350 );
options.arrowDirection = PopoverOptions.ARROW_DIRECTION_ANY;
Dialog.service.showSelectPopover( 1, "Genres", ["All", "Punk", "Rock", "Jazz"], options, [ 1 ] );