This page describes important details about using Y8 Account formerly id.net for Flash. It provides code that can be used in a AS3 application. We also have AS2 and AS3 example projects.

Important Notes

This SDK uses Flash Player 11 JSON features that are not available prior to Flash CS6. A workaround for CS5 and CS5.5 can be found on Adobe's website here. For Flash Develop, make sure you have the latest Flex SDK. Otherwise, please consider using the Flash CC trial or getting a 1 month subscription.

To avoid security warnings while downloading the SDK from a desktop enviroment, use the flash IDE, or add the output folder to flash's trusted locations.

How it Works

Each time a game is loaded, a small file is downloaded containing the Y8 interface. The code on this page explains how to load the Y8 Account file into a Flash project.

  1. Make a new text file named Y8.as and paste the first code sample in it. Save it to your project's root folder.
  2. Change the appId variable inside the Y8 file.
  3. Copy the second code sample into the beginning of your application or on the first frame.

Step 1 and 2

package {
	import flash.display.*;
	import flash.events.*;
	import flash.utils.*;
	import flash.net.*;
	import flash.system.*;

	public class Y8 extends MovieClip {
		public var sdk;
		private var appID:String = 'YOUR APP ID';// your application id
		private var verbose:Boolean = true;// display sdk messages
		private var showPreloader = false;// Display Traffic Flux preloader ad
		private var protection = false;// Enable information about sites that block links

		// All data is delivered to the handleIDNET function
		private function handleSDK(e:Event) {
			// uncomment the next 2 lines to see all data
			//trace(sdk.type);
			//trace(JSON.stringify(sdk.data));
			if (sdk.type == 'login') {
				trace('hello '+sdk.userData.nickname+' your pid is '+sdk.userData.pid);
			}
		}

		// Below is the loader for the Y8 interface. Do Not edit below.
		public function Y8() {
			Security.allowInsecureDomain('*');
			Security.allowDomain('*');
			addEventListener(Event.ADDED_TO_STAGE, onStage);
		}
		private function onStage(e:Event):void {
			var loaderContext:LoaderContext = new LoaderContext();
			loaderContext.applicationDomain = ApplicationDomain.currentDomain;
			if (Security.sandboxType != "localTrusted") {
				loaderContext.securityDomain = SecurityDomain.currentDomain;
			}
			var sdk_url:String = 'https://cdn.y8.com/swf/idnet-client.swc';
			var urlRequest:URLRequest = new URLRequest(sdk_url);
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete, false, 0, true);
			loader.load(urlRequest, loaderContext);
		}
		function loadComplete(e:Event):void {
			sdk = e.currentTarget.content;
			sdk.addEventListener('IDNET', handleSDK);
			stage.addChild(sdk);
			sdk.init(stage, appID, '', verbose, showPreloader, protection);
		}
	}
}

Step 3

If your app has problems recognizing the Y8 file, try importing it on the first line using an import statement. Otherwise, you can try adding it to your library.

// Add the Y8 object to the stage
var y8 = new Y8();
addChild(y8);

// You will want to connect this to a action like a button.
// calling it right away like this may not work until the interface is loaded
if(y8.sdk){// check if the sdk is loaded
	// show registration popup
	y8.sdk.toggleInterface('registration');
}

See all functions available on the reference page or continue reading about the other features from the main navigation.