GameKit is a native extension that allows the use of iOS GameKit framework. The extension allows your game to setup real time Game Center matches for up to 4 players, send and receive custom data between players, and enable voice chat during gameplay. It implements a subset of the iOS GameKit framework.


var gamekit:GameKit = new GameKit();

// Authenticate the local player, but listen to the events first:
gamekit.addEventListener(GameKit.LOCAL_PLAYER_AUTHENTICATED_EVENT, function(e:Event):void {

gamekit.addEventListener(GameKit.LOCAL_PLAYER_NOT_AUTHENTICATED_EVENT, function(e:Event):void {


//Get info about local player after successful authentication:
var localPlayer:LocalPlayer = gamekit.getLocalPlayer();

for (var friend:Player in localPlayer.friends)
    trace("friend: " + friend.displayName);

//Show native Game Center interface:

//Start a real time match, but listen to events first:
gamekit.addEventListener(GameKit.MATCH_MAKER_FAILED_EVENT, function(e:ErrorEvent):void {
    debug("MATCH_MAKER_FAILED_EVENT: " + e.errorID + ", " + e.text);

gamekit.addEventListener(GameKit.MATCH_MAKER_CANCELLED_EVENT, function(e:Event):void {

gamekit.addEventListener(GameKit.MATCH_MAKER_FOUND_MATCH_EVENT, function(e:MatchFoundEvent):void {
    debug("MATCH_MAKER_FOUND_MATCH_EVENT: " + JSON.stringify(e));

    match = e.match; // save the match somewhere
    if (match.expectedPlayerCount == 0)
        startGame(); // start game if not expecting anymore players

// bring up native match making interface for a match with 2 to 4 players
gamekit.startRealTimeMatch(2, 4);

// Send data to other players during game:
var data:ByteArray = new ByteArray();

// send a reliable packet to all players
match.sendDataToAll(data, true);

// send an unreliable packet to the match's first player
match.sendData(match.players[0], data, false);

// Receive data from other players:
match.addEventListener(RealTimeMatch.RECEIVED_DATA_EVENT, function(e:DataReceivedEvent):void {
    debug("RealTimeMatch.RECEIVED_DATA_EVENT from " + e.player.playerID + ": " +;

// Start a voice chat with other players:
var chat:VoiceChat = match.getVoiceChat("all");

// join the voice chat so the player can hear other players

// set talk to true so other players can hear this player = true;

// Disconnect and properly dispose the match:
match.dispose(); // releases the native match object
Air Native Extension, iOS . URL.