Skip to content

Instantly share code, notes, and snippets.

@FrancescoMaisto
FrancescoMaisto / GameCenterTest.as
Created December 11, 2013 22:22
Sample class to implement iOS GameCenter ANE from the Adobe Gaming SDK 1.3
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright [first year code created] Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
@FrancescoMaisto
FrancescoMaisto / gist:7408946
Last active December 27, 2015 23:49
Code sample to use the GameCenter ANE
import com.adobe.ane.gameCenter.GameCenterAuthenticationEvent;
import com.adobe.ane.gameCenter.GameCenterController;
private var gcController:GameCenterController;
private function initializeGameCenter():void
{
if (GameCenterController.isSupported)
{
trace ("gamecenter is supported");
@FrancescoMaisto
FrancescoMaisto / gist:7066021
Created October 20, 2013 07:28
Particle effects class
package gameboard
{
import starling.display.Sprite;
import starling.extensions.PDParticleSystem;
import starling.textures.Texture;
public class ParticleFXs extends Sprite
{
// Embed configuration XML
@FrancescoMaisto
FrancescoMaisto / ScrollingPanel.as
Created July 16, 2013 10:18
Page flipping using swiping gestures
package navigation.screens
{
import constants.Colors;
import constants.Constants;
import constants.Fonts;
import constants.Navigation;
import constants.Text;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.getTimer;
@FrancescoMaisto
FrancescoMaisto / SoundManager.as
Last active November 9, 2019 20:22
This ActionScript class makes dealing with sounds in Starling very easy and intuitive: once you add a sound to the SoundManager you can easily play it, stop it, change its volume, fade it in, fade it out or cross-fade it with another sound.See more details and usage examples below, in the first comment.
package starling.extensions {
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.utils.Dictionary;
import starling.core.Starling;
public class SoundManager {
@FrancescoMaisto
FrancescoMaisto / IdButton.as
Last active December 12, 2015 05:29
Extends the standard Starling Button by adding an id parameter. The id parameter can then be retrieved from the event dispatched to the 'onButtonTriggered' listener. (see usage example in the first comment)
package ui
{
import starling.display.Button;
import starling.textures.Texture;
/**
* Extends the standard Starling Button by adding an id parameter
*
* @author Francesco Maisto (www.francescomaisto.com)
*/
@FrancescoMaisto
FrancescoMaisto / getRandomNumber.as
Created February 6, 2013 10:06
Returns a random integer within the specified range (included)
package utils
{
/** Returns a random integer within the specified range (included) */
public function getRandomNumber(min:Number, max:Number):int
{
return Math.floor(Math.random() * (max + 1 - min)) + min;
}
}
@FrancescoMaisto
FrancescoMaisto / pickRandomNumberExcept.as
Last active December 12, 2015 05:28
Returns a random integer ranging from 1 to max, excluding numberToAvoid.
package utils
{
/** Returns a random integer ranging from 1 to max, excluding numberToAvoid. */
public function pickRandomNumberExcept(numberToAvoid:uint, max:uint):uint
{
// Create and populate a Vector to pick the numbers from, excluding numberToAvoid.
var numberContainer:Vector.<uint> = new Vector.<uint>();
for (var i:uint = 1; i <= max; i++)
{
if (i != numberToAvoid)
@FrancescoMaisto
FrancescoMaisto / pick4RandomNumbers.as
Last active December 12, 2015 05:28
Returns a 4 elements vector containing four different integers ranging from 1 to max, in random order.
package utils
{
/** Returns a 4 elements vector containing four different integers ranging from 1 to max, in random order. */
public function pick4RandomNumbers(max:uint):Vector.<uint>
{
// Create and populate a Vector to get 'max' different numbers from
var numberContainer:Vector.<uint> = new Vector.<uint>();
for (var i:uint = 1; i <= max; i++)
{
numberContainer.push(i);
package
{
public final class ObjectPool
{
private var MAX_VALUE:uint;
private var GROWTH_VALUE:uint;
private var TYPE:Class;
private var counter:uint;
private var pool:Array;