Requesting User Item Instances
The inventory of any user can be requested by using the requestUserItemList method. This function takes a username string as the first argument, but you may pass in null or a blank string to request the inventory for the current user. The second argument is a callback function to call when retrieval is complete.
requestUserItemList(username:String,callback:Function):void
username:String- The username to request inventory for, ornullfor the current player.callback:Function- The callback function
The callback will be called with a single Object argument which has two fields:
success:Boolean - True if successfuldata:Array - List of item instanceObjects(if successful):id:Number - Database ID of the item instanceidentifier:String - Item identifier stringdata:String - Item metadata (attached at checkout time)remaining_uses:Number - Number of uses remaining
Example: Request the inventory for the current player
// Request the inventory for the current player
kongregate.mtx.requestUserItemList(null, onUserItems);
// The callback function
function onUserItems(result:Object):void{
trace("User item list received, success: " + result.success);
if( result.success ){
for( var i:int = 0; i < result.data.length; i++ ){
var item:Object = result.data[i];
trace((i+1) + ". " + item.identifier + ", " + item.id + "," + item.data);
}
}
}
Comments