This page describes important details about using 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 id.net interface. The code on this page explains how to load the id.net file into a Flash project. Complete the following 3 steps to begin using id.net for Flash.

  1. Make a new text file named IDI.as and paste the first code sample in it. Save it to your project's root folder.
  2. Change the appId variable inside the IDI 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 IDI extends MovieClip {
        public var idnet;
        private var appID:String = 'YOUR APP ID';// your application id
        private var verbose:Boolean = true;// display idnet 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 handleIDNET(e:Event) {
            // uncomment the next 2 lines to see all data
            //trace(idnet.type);
            //trace(JSON.stringify(idnet.data));
            if (idnet.type == 'login') {
                trace('hello '+idnet.userData.nickname+' your pid is '+idnet.userData.pid);
            }
        }

        // Below is the loader for the id.net interface. Do Not edit below.
        public function IDI() {
            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://scdn.id.net/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 {
            idnet = e.currentTarget.content;
            idnet.addEventListener('IDNET', handleIDNET);
            stage.addChild(idnet);
            idnet.init(stage, appID, '', verbose, showPreloader, protection);
        }
    }
}

Step 3

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

// Add the IDI object to the stage
var idi = new IDI();
addChild(idi);

// 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(idi.idnet){// check if idnet is loaded
    // show registration popup
    idi.idnet.toggleInterface('registration');
}

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