ChartBoost

ChartBoost is a native extension to use ChartBoost advertisements. This extension was developed by the ChartBoost team, so it provides an official implementation of the service API. The extension works on Android and iOS, allowing developers to use the same set of methods on both platforms.

The extension has methods to cache and show different types of ads, such as interstitials and “more apps”. Several events are available to inform the current state of the extension, e.g. ad was cached, ad was showed, ad dismissed, ad failed to load. The extension itself is also able to inform the developer if the system it’s running on is Android or iOS.

Sample

import com.chartboost.plugin.air.Chartboost;
import com.chartboost.plugin.air.ChartboostEvent;

private var chartboost:Chartboost;

private function init():void {
	localTrace("Chartboost Actionscript init()");
	// init
	chartboost = Chartboost.getInstance();
	if (Chartboost.isAndroid()) {
		chartboost.init("4f7aa26ef77659d869000003", "ee759deefd871ff6e2411c7153dbedefa4aabe38");
	} else if (Chartboost.isIOS()) {
		chartboost.init("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");
	}

	// add listeners
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_CACHED, onAdCached);
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_SHOWED, onAdShowed);
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_DISMISSED, onAdDismissed);
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_FAILED, onAdFailed);
}

private function onAdShowed( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial showed: ", event.location );
}

private function onAdCached( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial cached: ", event.location );
}

private function onAdDismissed( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial dismissed: ", event.location );
}

private function onAdFailed( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial failed to load: ", event.location );
}

public function localTrace(log:String, log2:String = ""):void {
	logs.text = logs.text + "\n" + log + " \t" + log2;
}

Chartboost.getInstance().cacheInterstitial();
Chartboost.getInstance().showInterstitial();	
trace(Chartboost.getInstance().hasCachedInterstitial().toString());

Chartboost.getInstance().cacheMoreApps();
Chartboost.getInstance().showMoreApps();
trace(Chartboost.getInstance().hasCachedMoreApps().toString());
MIT
Comments Off on ChartBoost

Parallax Effect

Parallax Effect is a native extension to create parallax effect in any application. It allows the developer to add and move as many layers as desired. The developer just adds the layers and the extension takes care of moving and stacking them together. The extension provides some events that can be listened to know the offset X and Y of a layer, for instance.

It’s possible to use the offset information to create custom animation, or to optimize the moving process using any tweening engine. The extension has a set of features, such as add layers (any DisplayObject), Starling integration, the ability to control the direction and movement multiplier of each layer,  uses the device’s rotation sensor to move layers and doesn’t require special permissions.

Sample

import com.doitflash.air.extensions.parallax.Parallax;
import com.doitflash.air.extensions.parallax.ParallaxEvent;

var _orgLayer1_X:Number;
var _orgLayer1_Y:Number;
var _orgLayer2_X:Number;
var _orgLayer2_Y:Number;
var _orgLayer3_X:Number;
var _orgLayer3_Y:Number;

// add parallax layers to the app
_layer1 = new Layer1(); // can be any DisplayObject
_layer1.x = -100;
_layer1.y = -100;
_orgLayer1_X = _layer1.x;
_orgLayer1_Y = _layer1.y;
this.addChildAt(_layer1, 0);

_layer2 = new Layer2(); // can be any DisplayObject
_layer2.x = 200;
_layer2.y = 100;
_orgLayer2_X = _layer2.x;
_orgLayer2_Y = _layer2.y;
this.addChildAt(_layer2, 1)

_layer3 = new Layer3(); // can be any DisplayObject
_layer3.x = 200;
_layer3.y = 100;
_orgLayer3_X = _layer3.x;
_orgLayer3_Y = _layer3.y;
this.addChildAt(_layer3, 1)

// set Extension var
var _ex:Parallax; 

// initialize the extension
_ex = new Parallax();

if (!_ex.isSupport) return;

// The first step to start the Parallax effect is to introduce the the layers which you'd like to animate.
// $maxXMovement: The max movement value for every layer on X axle
// $maxYMovement: The max movement value for every layer on Y axle
// $layers:    is an array containing information about each layer object.
// NOTE:     The must have data about each layer are: "name", "fx" and "fy".
// NOTE:     Value of "fx" and "fy" should be between -1 and 1. if this multiplier is 1 or -1, the movement value will be set according to the maxXMovement and maxYMovement. if their value is near to 0, the movement value will be less.
//             if the multiplier value is negative, it's movement will be oposite.
// EXAMPLE: [ { name:'layer1', fx:-0.4, fy:-0.4 }, { name:'layer2', fx:-0.5, fy:0.5 }, { name:'layer3', fx:1, fy:1 } ]
// NOTE: this method must be called prior to the "start" method.
// NOTE:     The offset values that you will receive from the extension are between -maxXMovement and +maxXMovement OR -maxYMovement and +maxYMovement
//             to move your layers around, you should add this value to your original X and Y position of your layer.
// NOTE: on landscape mode, use "offx" for the "Y" of your layer and "offy" for the "X" of your layer.
// NOTE: considering that the Parallax extension will move your layers to left and right, it's important to place your layers initially in a good position.
// 
// param $maxXMovement
// param $maxYMovement
// param $layers
_ex.initLayers(100, 100, [ { name:'layer1', fx:-0.4, fy:-0.4 }, { name:'layer2', fx:-0.5, fy:0.5 }, { name:'layer3', fx:1, fy:1 } ]);

// Use this listener to receive the layers offset information.
_ex.addEventListener(ParallaxEvent.NEW_MOVEMENTS, onLayersMovement)

// As soon as you call this method, the ParallaxEvent.NEW_MOVEMENTS listener will receive the offset data.
// NOTE: Prior to calling this method, you must had called _ex.initLayers
_ex.start();

// Call this method and the offset information will not be returned by the extension anymore.
_ex.stop();

//some rare devices may not support the orientation sensor. call this property to check if it is available.
 var isSupport:Boolean = _ex.isSupport;
 trace("isSupport >> " + isSupport);

function onLayersMovement(e:ParallaxEvent):void {
     // NOTE: on every time the ParallaxEvent.NEW_MOVEMENTS listener is called, information about each layer will be returned.
     // every layer is in an object. Please note that you had previously named your layers. here you can use those names to identify the layers. 
     // EXAMPLE: [ { name:'layer1', offx:-40, offy:-40 }, { name:'layer2', offx:-50, offy:50 }, { name:'layer3', offx:100, offy:100 } ]
     var arr:Array = e.param;
     var i:int = 0;
     var lng:int = arr.length;

     for (i = 0; i < lng; i++) {
        // to animate the layers better, you may use any Tween engine. we use TweenMax, but you can use any other engine of your choice.

        var obj:Object = arr[i];
        if (obj.name == "layer1") {
            _layer1.x = _orgLayer1_X + obj.offx;
            _layer1.y = _orgLayer1_Y + obj.offy; 
            // TweenMax.to(_layer1, 0.25, { x:(_orgLayer1_X + obj.offx), y:(_orgLayer1_Y + obj.offy), ease:Easing.Expo_easeOut } ); 
         }

         if (obj.name == "layer2") {
             _layer2.x = _orgLayer2_X + obj.offx;
             _layer2.y = _orgLayer2_Y + obj.offy; 
             // TweenMax.to(_layer2, 0.25, { x:(_orgLayer2_X + obj.offy), y:(_orgLayer2_Y + obj.offx), ease:Easing.Expo_easeOut } ); 
         }

         if (obj.name == "layer3") {
             _layer3.x = _orgLayer3_X + obj.offx;
             _layer3.y = _orgLayer3_Y + obj.offy; 
             // TweenMax.to(_layer3, 0.25, { x:(_orgLayer3_X + obj.offx), y:(_orgLayer3_Y + obj.offy), ease:Easing.Expo_easeOut } );
         }
     }
}
Commercial
5 Comments

fuzzylogic

fuzzylogic is a minimal and fast Fuzzy logic engine for games. When coding the AI of a game entity, for instance, developers usually organize rules and thoughts using if statements. If a condition is evaluated to true, e.g. enemy is close, then the actions within the if block that holds that condition will be executed. This pattern usually produces crisp and robotic results, since all conditions are very specific questions containing just a single answer (true or false).

This library enables the use of Fuzzy logic to enhance AI development. A developer can connect condition values, e.g. distance to the enemy, with a fuzzy module. The whole operation can be customized using different ranging function. The fuzzy logic usually overlaps the results from different conditions, producing convincing results. E.g. An entity must shoot using weapon A if an enemy is close, but it can shoot using weapon B, occasionally.

Fuzzy rules can be defined using natural language, which helps to write better and advanced behaviors easily.

Sample

fuz=new Fuzzyficator();
manifold = new FuzzyManifold("Distance_to_Target");
var distanceStatusInput:FuzzyInput=new FuzzyInput();
manifold.input = distanceStatusInput;
//Close would be everything(every distance) from 0 to 125
func = factory.create(FuzzyMembershipFunction.LEFT_SHOULDER, "Close", 0,25, 125 );
//Medium distance would be from 25 to 300  
func = factory.create(FuzzyMembershipFunction.TRIANGLE, "Medium", [25 150 300] );
manifold.addMember(func);
//Far would be everything from 150 to 400
func = factory.create(FuzzyMembershipFunction.RIGHT_SHOULDER, "Far", "150, 300,400","," );
manifold.addMember(func);
//You can add function base points with separator, or like array [] or like string with separator.
rule = new FuzzyRule( " IF Distance_to_Target IS Far AND  Ammo_Status IS Low THEN Desirability IS Undesirable ");
fuz.addRule(rule);
rule = new FuzzyRule( "IF Distance_to_Target IS Medium AND Ammo_Status IS Loads THEN Desirability IS VeryDesirable ");
fuz.addRule(rule);
rule = new FuzzyRule( "IF Distance_to_Target IS Medium AND Ammo_Status IS Okey THEN  Desirability IS VeryDesirable ");
fuz.addRule(rule);
fuz.Fuzzify();
fuzzyManifolds = fuz.Defuzzify(DefuzzificationMethod.CENTROID);
trace("OUTPUT COG:" + FuzzyManifold(fuzzyManifolds["Desirability"]).output);
MIT
4 Comments

ImmaBoid

ImmaBoid is an AI steering behavior library for FlashPunk. In order to be affected by any behavior, an entity must extend the base Boid class, which extends FlashPunk’s entity class to add mass, velocity, and maxspeed to the entity. Any boid supports multiple behaviors, including the ability to sort the behaviors to start from.

Any behavior can be added to a boid through the method addBehavior(), which receives a behavior as a parameter. Every behavior has its own set of configuration parameters, e.g. the target to pursuit. The library has the following behaviors available: seek, flee, arrival, pursuit, evade, wander and follow path.

Sample

public class Zomboid extends Boid {
    public function Zomboid(x:Number = 0, y:Number = 0) {
        super(x, y);

        maxSpeed = 150;
        mass = 10;
    }
}

var z:Zomboid = new Zomboid();
z.addBehavior(new FleeBehavior(someScaryBoid);
z.addBehavior(new FollowPathBehavior(pathToAwsome, 20));
1 Comment

Codebot devlog 001 – foundation

This post is part of a series describing the development of Codebot, an open-source IDE focused on game development. Check out the other posts of the series here.

Codebot development has been on fire! It’s been 3 weeks since I started the project and I’ve managed to find some free time (and a lot of effort) to accomplish my first milestone. As I initially described, my priority goal is to lay down the foundation of a text editor, which involves everything related to writing/reading text files.

Below is a screenshot of my current progress:

Codebot  pre-alpha 002

I’ve already implemented the following features:

  • Choose a folder to be listed on “files panel” (white panel on the right);
  • Open, edit and save files;
  • Keep several files open at the same time using tabs to switch between them;
  • Move files and folders around in the “files panel” (used to re-structure a project, for instance);
  • Rename files/folders in the “files panel”;
  • Use a JSON file to store the IDE preferences (e.g. smart indentation, tab size, etc).

Under the hood there is a lot of code to implement all that and still make sure Codebot will be able to run on different platforms. Despite that, I focused on getting it to work on a single platform (Mac) at first. When things are working the way they should, I can spend some time implementing the missing IO layers.

In order to make Codebot a complete text editor, I must implement the following:

  • Create new files/folders using shortcuts or the “files panel”;
  • Save a file without closing it;
  • Manager for shortcuts (that’s an optional task, but I’ll probably implement it anyway)

Unfortunately the exams season is about to begin at the university, which will drastically reduce my free time. I hope to implement the remaining tasks until I run out of free time.

In the next post I will dissect Codebot structure and expose the libs and technologies I’m using or planning to use.

codebot gamedev IDE
7 Comments

AutoCall

AutoCall is a native extension to initiate a phone call then return to the app upon call completion. This extension overcomes the most common problems with similar libs, e.g some Android devices won’t allow the application to actually make a call, they just copy the number to the phone app or the clipboard, and iPhones won’t return to the application upon call completion.

The extension comes with a package including a demo APK, the demo FLA with commented code, sample application descriptor, the ANE itself and a README file.

Sample

var my_ane:AutoCallANE = new AutoCallANE();
my_ane.callPhone(5555555555);
Commercial
1 Comment

Sparticle

Sparticle is a professional grade GUI tool to create and edit particle effects on Away3D. It is completely GPU-accelerated and is ideal for game-effect designers who want to develop complex 3D effects for their games. The tool provides several panels to adjust particles properties, such as animation, behavior, texture, velocity, etc.

After the effect is ready to be used, the developer has the option to export or upload it to effecthub.com (a popular database of game effects). An exported effect can be loaded into Away3D by Sparicle own parser.

Sparticle

Free
2 Comments

iAd

iAd ANE is a native extension to show iAd ads on iOS. It supports all native functions, allowing developers to fine-tune how advertisements are displayed. Even though the extension includes all size types and interstitials,  the Apple ad network restricts the ad type by device. Banners can be used in iPhone/iPads, while interstitials can be used on iPad only.

In order to check if a banner type can be displayed, the extension has a method to check if interstitials are supported. It allows developers to selectively show ads based on the device running the application. This extension can be centralized and managed by the Ad Network ANE.

Sample

if(IAd.getInstance().supportDevice) {                                        
    IAd.getInstance().showBanner(IAd.BANNER,IAdPosition.BOTTOM_CENTER);
}

// Check ane support. Apple does not provide Interstitial ad on iphone.
if(IAd.getInstance().supportDevice&&IAd.getInstance().supportedInterstitial){
    IAd.getInstance().addEventListener(IAdEvent.onInterstitialReceive,onAdReceived);
    IAd.getInstance().cacheInterstitial();
}

protected function onAdReceived(event:IAdEvent):void {
    if(event.type == IAdEvent.onInterstitialReceive) {
        IAd.getInstance().showInterstitial();
    }
}
Apache 2.0
2 Comments

Chartboost SDK

Chartboost SDK is a native extension to show ads from Chartboost on Android and iOS. It has a clean and easy to use API, containing several methods to show interstitials and More App Pages. Both ad calls can be cached, which allows the developer to wait until the ad has been completely loaded before it can be displayed.

The extension has a few events that can be monitored to control the process. When an interstitial is cached, for instance, the extension start loading its information. When the loading process is done or an error occurs, an event is fired. This extension can be centralized and managed by the Ad Network ANE.

Sample

chartboost = Chartboost.getInstance();
chartboost.setInterstitialKeys(this.appid, this.sign);
chartboost.addEventListener(AdEvent.onInterstitialReceive, onAdReceived);

if (!chartboost.supportDevice) {
  trace("not support device");
  return
}  else  {
  if(chartboost.isInterstitialReady()){
    chartboost.showInterstitial();
  } else {
    chartboost.cacheInterstitial();
  }

  if(chartboost.isMoreAppReady()){
    chartboost.showMoreApp();
  } else {
    chartboost.cacheMoreApp();
  }
}

protected function onAdReceived(event:AdEvent):void {
  chartboost.showInterstitial();
}
Apache 2.0
3 Comments

ascsh

ascsh is a wrapper for the new ActionScript Compiler 2.0. It was modeled to be roughly equivalent to the older Flex Compiler’s fcsh and fcshd. It improve AS3/AIR/SWF/SWC project compilation performance by maintaining a persistent JVM compiler process.

The tool is followed by a daemon named ascshd, which is a convenience wrapper around ascsh itself. It starts a background server thread to maintain the ascsh process, and sends commands to it for builds. This way, the build can simply call ascshd again and again from the build system (no fussy shell) and it just gets faster over time.

MIT
1 Comment

dotMath

dotMath is a 2D, 3D math library. It provides several classes with different purposes, such as positioning (Vector2, Vector3 and Quaternion), color/matrix manipulation and 3D transformations. The matrix classes have methods to calculate the determinant, reduce to identity and transpose, as well as structure to handle 3×3 and 4×4 sizes.

Regarding the vector classes,  it’s possible to add/subtract them, scale, normalize and calculate its magnitude (length). There is also some methods in this package useful to perform common gamedev tasks, such as calculate the distance between a point and a line.

Sample

var v1:Vector2 = new Vector2( 1, 2 );
var v2:Vector2 = new Vector2( 1, 2 );

var v3:Vector2 = Vector2.subtract( v1, v2 );
v3.normalize();
MIT
3 Comments

Codebot: an IDE focused on gamedev

This post is part of a series describing the development of Codebot, an open-source IDE focused on game development. Check out the other posts of the series here.

I decided to kick off 2014 with a project that I’ve been willing to develop for a while. I had this idea in 2013 while struggling to overcome some pretty common gamedev tasks. My idea is to create an IDE focused on gamedev. Meet Codebot!

Why, man, WHY?! There are so many IDEs already!

I know that, but none of them is able to solve most (or all) of my gamedev problems. Developing a game is much more than just coding, you have to tweak art, build levels, convert files, find assets/extensions, read docs about building and publishing, and so on. If you are just like me, anything but code is damn boring.

I don’t like spending time to find out what are the dimensions and formats of thumbnails/icons for Google Play, or what witchcrafts I have to put a PNG file through so it can be accepted by Apple. I don’t like to crawl the internet after SFXs, then discover I need to convert it from WAV to MP3 so it can be used. I don’t like to manually slice assets to extract tiles. My IDE should help me do that, or do it all by itself!

Uh? I didn’t get your point…

I want something like magic, a magic “sliding panel” to be more precise:

codebot_ide_001Imagine you are working on your Ludum Dare game and you need an 8-bit SFX. You click a button, a panel slides, you type in a few keywords, select what you want and done! Want to create icons to publish your game on Google Play? Slide a panel, add a single 1024×768 PNG image and hit publish. Done, all icons are ready!

That’s the sort of thing I’m trying to achieve. I want an IDE that helps me develop a game, something that minimizes the time I spend working around “non-gamedev” problems. I want to focus on making games.

Ok, got it! You are insane! It won’t work

I might fail or maybe nobody will use my IDE (including myself, in the worst case scenario :D). That doesn’t bother me at all. I decided to give this project a try because a) it seems damn fun to code and b) it might end up helping others. I coded a lot of things until today, but never a gamedev IDE. I don’t want to create more of the same, I want to create something new.

I have my favorite IDEs now, which include FlashDevelop and Brackets, but they have their own problems: FlashDevelop doesn’t work on Mac, Brackets can’t be used to code As3, and more. Don’t get me wrong, I love them, but I want to try to improve my gamedev experience.

So what features are you planning?

If you read until this point, you are probably interested on my idea. Thanks! Below is a short list of the features I want Codebot to have (no particular order):

  • Create icons in all sizes required by Google, Apple, OUYA, etc using a single PNG image;
  • Build to different platforms using as few configuration as possible (e.g. build APK for Android and EXE for Windows, wrapping/compiling them the best way possible);
  • Smart files: open a CSV file that describes a level (tilemap), the IDE offers the possibility to render that file if you provide a spritesheet;
  • Easily find and download music/SFX using a sliding panel;
  • Package sprites into an atlas;
  • Extract sprites/tiles from image;
  • Easy development steps. E.g. built-in web server for HTML5 gamedev;
  • Easily find and add extensions/libs to a project (slide a panel, search, click integrate, done!).

That’s what I have planned so far.

That’s a lot, how will you develop all that?

My current plan is to implement the code editing parts first, which includes open/saving files, etc. After that I want to start adding building options, starting with Flash/AIR then HTML5. When everything is usable, I will jump into the sliding panels. Probably the first panel will be something to add AIR native extensions to Flash projects.

If you are interested on Codebot, follow its development on this blog and on Github. More technical stuff will come as I progress.

codebot gamedev IDE tools
9 Comments

nexuslib

nexuslib is a library that provides robust reflection support, random number generation, cryptography, networking, and more.  The reflection and serialization packages have among their features deterministic JSON de/serialization, deserializing directly to typed AS objects, a structured reflection class heirarchy, and more. It also has full support for Application Domains and namespaces.

The crypto and security package offer an HMAC class and some utilities, useful to protect content. The nexuslib also has packages to work with version control systems, such as git.

Sample

// Class nexus.math.Random
public static function get instance():Random;
public function Random(generator:IPRNG);
public function float(min:Number = NaN, max:Number = NaN):Number;
public function integer(min:uint = 0, max:int = int.MAX_VALUE):int;
public function unsignedInteger(min:uint = 0, max:uint = uint.MAX_VALUE):uint;
public function boolean():Boolean;
public function weightedRound(value:Number):int;
public function choice(... items):Object;
public function shuffle(container:Object):void;
public function toString(verbose:Boolean = false):String;
Mozilla Public 2.0
2 Comments

Ad Network

Ad Network is a native extension to manage and centralize the process of displaying ads from a variety of publishers on mobile applications. The extension comes with built-in support for AdMob ( iOS, Android), InMobi (iOS, Android), Chartboost (iOS, Android) and iAd (iOS). If a different ad publisher is not available, a developer can easily write a plugin to implement the missing ad service.

The built-in plugins come as separate SWCs the developer must download. Each SWC is self-contained and can be used separately, but the Ad Network extension unifies them all under the same API. When showing an ad, the extension will try to load the first from the list of available publishers; if the ad is not loaded, the next service is used, and so on.

Sample

var list: Vector  = new Vector  ();
list.push(new AdItem(new AdmobAdapter(), 10, "admob app id", "", 5));
list.push(new AdItem(new InmobiAdapter(), 10, "inmobi app id"));
AdManager.getInstance().configPlatforms(list);

AdManager.getInstance().showInterstitialOrCache();
AdManager.getInstance().showBannerAbsolute(AdSize.PHONE_PORTRAIT, x, y);
AdManager.getInstance().showBanner(AdSize.PHONE_PORTRAIT,AdPosition.BOTTOM_CENTER);
Apache 2.0
3 Comments

Air-Mobile-ScrollController

Air-Mobile-ScrollController is a library to control the scrolling process of an application. The library handles all the scrolling manipulation of the content, producing a smooth result that reassembles the native scroll movement. It has an API for mobile and web applications.

The library works based on two rectangles, one representing the content and the other one acting as a container. It’s possible to individually control horizontal and vertical scrolling, as well as read the current position in the scrolling area. There are several methods to smoothly scroll to a specific position, e.g. the origin. An animation is used to transition between any scrolling positions.

Sample

package com.freshplanet.lib.ui.scroll.mobile.example
{
	import com.freshplanet.lib.ui.example.util.RectangleSprite;
	import com.freshplanet.lib.ui.scroll.mobile.ScrollController;

	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Rectangle;

	public class ScrollControllerExample extends Sprite {
		private var _scroll:ScrollController;

		public function ScrollControllerExample() {
			super();

			this.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);
			this.addEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
		}

		private function onAddedToStage(e:Event):void {
			this.removeEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);

			var container:RectangleSprite = new RectangleSprite(0x440000, 50, 50, this.stage.stageWidth - 100, this.stage.stageHeight - 100);//red background
			this.addChild(container);

			var content:RectangleSprite = new RectangleSprite(0x444477, 0, 0, this.stage.stageWidth - 100, this.stage.stageHeight * 2, 30);//blue foreground
			container.addChild(content);

			var containerViewport:Rectangle = new Rectangle(0, 0, this.stage.stageWidth - 100, this.stage.stageHeight - 100);

			this._scroll = new ScrollController();
			this._scroll.horizontalScrollingEnabled = false;
			this._scroll.addScrollControll(content, container, containerViewport);
		}

		private function onRemovedFromStage(e:Event):void {
			this.removeEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);

			this._scroll.removeScrollControll();
		}
	}
}
Apache 2.0
5 Comments