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.

API Functions

Exporting the 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.lineStyle(1);
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 :(")
  }
}

Comments