Kongregate Developers

Kongregate Avatar Export API (AS3 only)

Kongregate's Avatar Export API gives you the ability to export in-game avatars and let users use them as their Kongregate profile avatar. When you call the submitAvatar function, the user will receive a notification that the game is requesting to change their avatar. At that point, they'll be able to crop the suggested image if they wish, and can choose to accept or decline the avatar modification. This functionality can be used to provide bonuses for players, as well as more directly with avatar creator/editor apps, and probably other uses we haven't even thought of yet.

Exporting an Avatar

You can use the submitAvatar function to export a DisplayObject to be converted to a user avatar. It is highly recommended that avatars be at least 40x40px.

submitAvatar(avatar:DisplayObject, callback:Function):void
  • avatar:DisplayObject - Can be null, but highly recommended that you send yourself. If null, we will snapshot the stage.
  • callback:Function - Function to call when content load request has been made

The callback function must accept a single Boolean which will be true if the user has accepted the avatar and false if they decide not to use it.

Example: Exporting a rectangle:

var rect:Shape = new Shape();
rect.graphics.beginFill(0x0000FF, 1);
rect.graphics.drawRect(0, 0, 75, 50);

kongregate.images.submitAvatar(rect, onAvatarComplete);

function onAvatarComplete(success:Boolean) {
  if(success) {
    trace("That user must love rectangles!")
  } else {
    trace("Next time I'll try a triangle :(")