{"_id":"56acd12a693f0a0d0085f099","project":"56abbf55f25f160d00e17f4e","category":{"_id":"56abca6bf9757e0d007c6650","pages":["56abcb4a678b58170031ec27","56accf7513ac890d001c3c76","56acd12a693f0a0d0085f099","56acd43d0ab3c00d00ce332d","56acd698d21f1b0d00fd2f65"],"project":"56abbf55f25f160d00e17f4e","__v":5,"version":"56abbf55f25f160d00e17f51","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-29T20:24:11.577Z","from_sync":false,"order":1,"slug":"api-overview","title":"API Languages"},"parentDoc":null,"user":"56abbec30b9e0b0d00616274","__v":4,"version":{"_id":"56abbf55f25f160d00e17f51","project":"56abbf55f25f160d00e17f4e","__v":12,"createdAt":"2016-01-29T19:36:53.665Z","releaseDate":"2016-01-29T19:36:53.665Z","categories":["56abbf56f25f160d00e17f52","56abca6bf9757e0d007c6650","56acddfa0ab3c00d00ce3332","56af65da9d32e30d0006d30f","56af66cab34d210d003d9ad0","56af6afcd21e9c0d00b628d1","56af6d6ecc4cbd0d00ce2c88","5705b12221cfed0e00e8c580","570a5676ade45d0e00c1ad33","570d7d25d1e4b82000d9e385","570eac3c3160d10e0041df0e","575709000fd6a3200010dded"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-30T15:05:14.493Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Deprecated\",\n  \"body\": \"The AS2 API is no longer being actively developed, and is no longer fully supported\"\n}\n[/block]\n## Kongregate's ActionScript 2 API\n\nThe Kongregate ActionScript 2 (AS2) API allows you to extend your game to communicate with the Kongregate back-end. The API is automatically loaded for all ActionScript 2 games, so there is nothing to download or install in order to integrate.\n\n### Accessing the API and Connecting\n\nIn order to access the Kongregate API object, you can simply get a reference to it from the `_global` space. It is good practice to call the `connect` method as soon as possible, as shown in the code below:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var kongregate = _global.kongregate;\\nkongregate.services.connect();\",\n      \"language\": \"javascript\",\n      \"name\": \"ActionScript 2\"\n    }\n  ]\n}\n[/block]\n### The Kongregate API Object\n\nAs you can see in the code above, we keep a reference to the \"Kongregate API\" object and store it in the variable named `kongregate`. This is the assumption that is made for the remainder of the documentation, so if you store this reference in a different way, make sure to modify the examples accordingly. For ActionScript 2, you can always just use the `_global` reference, and substitute in `_global.kongregate` wherever you see the `kongregate` variable in the sample code.\n\nOnce the API is loaded, you can start using functions from the [Client API](doc:client-api-introduction) in your application.","excerpt":"","slug":"actionscript-2-api","type":"basic","title":"ActionScript 2 API"}

ActionScript 2 API


[block:callout] { "type": "warning", "title": "Deprecated", "body": "The AS2 API is no longer being actively developed, and is no longer fully supported" } [/block] ## Kongregate's ActionScript 2 API The Kongregate ActionScript 2 (AS2) API allows you to extend your game to communicate with the Kongregate back-end. The API is automatically loaded for all ActionScript 2 games, so there is nothing to download or install in order to integrate. ### Accessing the API and Connecting In order to access the Kongregate API object, you can simply get a reference to it from the `_global` space. It is good practice to call the `connect` method as soon as possible, as shown in the code below: [block:code] { "codes": [ { "code": "var kongregate = _global.kongregate;\nkongregate.services.connect();", "language": "javascript", "name": "ActionScript 2" } ] } [/block] ### The Kongregate API Object As you can see in the code above, we keep a reference to the "Kongregate API" object and store it in the variable named `kongregate`. This is the assumption that is made for the remainder of the documentation, so if you store this reference in a different way, make sure to modify the examples accordingly. For ActionScript 2, you can always just use the `_global` reference, and substitute in `_global.kongregate` wherever you see the `kongregate` variable in the sample code. Once the API is loaded, you can start using functions from the [Client API](doc:client-api-introduction) in your application.