Kongregate Developers

API Functions

Adding load event listeners

You can use the addLoadListener function to register an event listener which will be triggered when shared content of the specified type is loaded by the user.

addLoadListener(contentType:String, callback:Function):void
  • contentType:String - Type of content to listen for
  • callback:Function - Function to call when content load request has been made

The callback function must accept a single Object which will have the following properties:

  • id:Number - The id of the shared content
  • name:String - The name of the shared content
  • permalink:String - A link to the shared content
  • content:String - The content itself
  • label:String - The label for the content

Example: Loading shared content with "Contraption" as the content type:

kongregate.sharedContent.addLoadListener("Contraption", onContraptionLoad);

function onContraptionLoad(params:Object) {
  var id:Number        = params.id;
  var name:String      = params.name;
  var permalink:String = params.permalink;
  var content:String   = params.content;
  var label:String     = params.label;
  trace("Contraption " + id + " [" + label + "] loaded: " + content);