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 forcallback: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 contentname:String- The name of the shared contentpermalink:String- A link to the shared contentcontent:String- The content itselflabel: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);
}
Comments