Package | com.whirled.game |
Class | public class PlayerSubControl |
Inheritance | PlayerSubControl ![]() ![]() ![]() |
Method | Defined by | ||
---|---|---|---|
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener.
| AbstractControl | |
awardPrize(ident:String, playerId:int):void
Awards the specified prize item to this client's player (the default) or a specified player.
| PlayerSubControl | ||
awardTrophy(ident:String, playerId:int):Boolean
Awards the specified trophy to this client's player (the default) or a specified player.
| PlayerSubControl | ||
![]() |
doBatch(fn:Function, ... args):void
Execute the specified function as a batch of commands that will be sent to the server
together.
| AbstractSubControl | |
getCookie(callback:Function, occupantId:int):void
Get the user-specific game data for the specified occupant.
| PlayerSubControl | ||
getPartyId(occupantId:int):int
Get the specified player's partyId, or 0 if they're not in a party.
| PlayerSubControl | ||
getPlayerItemPacks(playerId:int):Array
Returns all item packs owned by this client's player (the default) or a specified player.
| PlayerSubControl | ||
getPlayerLevelPacks(playerId:int):Array
Returns all level packs owned by this client's player (the default) or a specified player.
| PlayerSubControl | ||
holdsTrophy(ident:String, playerId:int):Boolean
Returns true if this client's player (the default) or a specified player has the trophy
with the specified identifier.
| PlayerSubControl | ||
![]() |
isConnected():Boolean
Are we connected and running inside the whirled environment, or has someone just
loaded up our SWF by itself?
| AbstractSubControl | |
isRegistered():Boolean
Returns true if this player is a full registered member of Whirled, false if they are an
anonymous guest.
| PlayerSubControl | ||
![]() |
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Unregisters an event listener.
| AbstractControl | |
requestConsumeItemPack(ident:String, msg:String):Boolean
Requests to consume the specified item pack.
| PlayerSubControl | ||
setCookie(cookie:Object, occupantId:int):Boolean
Store persistent data that can later be retrieved by an instance of this game.
| PlayerSubControl |
Event | Summary | Defined by | ||
---|---|---|---|---|
Dispatched when this player has been awarded coins. | PlayerSubControl | |||
Dispatched when this player has purchased new game content. | PlayerSubControl | |||
Dispatched when this player has consumed an item pack. | PlayerSubControl | |||
![]() | Event.UNLOAD Dispatched when the SWF using this control has been unloaded. | AbstractControl |
Constant | Defined by | ||
---|---|---|---|
CURRENT_USER : int = 0 [static] ID constant passed to cookie, prize and trophy functions to refer to the current player.
| PlayerSubControl |
awardPrize | () | method |
public function awardPrize(ident:String, playerId:int):void
Awards the specified prize item to this client's player (the default) or a specified player. If the supplied prize identifier is not valid, this will not be known until the request is processed on the server, so the method will return successfully but no prize will have been awarded. Thus you should be careful not to misspell your prize identifier in your code or in the associated prize item.
Note: a game is only allowed to award a prize once per game session. This is to guard against bugs that might try to award many hundreds of the same prize to a user while playing a game. If you really want to award multiple instances of a prize, you will need to make different prize items with unique identifiers which all reference the same target item.
Note also: because a game can award the same prize more than once if the player earns the prize in separate game sessions, a game that wishes to only award a prize once should couple the award of the prize with the award of a trophy and then structure their code like so:
if (_ctrl.awardTrophy("special_award_trophy")) { _ctrl.awardPrize("special_award_avatar"); }
The first time the player accomplishes the necessary goal, they will be awarded the
trophy and the prize. Subsequently, awardTrophy()
will return false indicating
that the player already has the trophy in question and the prize will not be awarded.
Alternatively the game could store whether or not the player has earned the prize in a user
cookie.
Note thirdly: Clients may only award prized to the current player. Server agents do not have a current player and therefore must pass in a valid player id.
Parametersident:String — the identifier of the prize to award
|
|
playerId:int — the id of the player to award the prize to
|
awardTrophy | () | method |
public function awardTrophy(ident:String, playerId:int):Boolean
Awards the specified trophy to this client's player (the default) or a specified player. If the supplied trophy identifier is not valid, this will not be known until the request is processed on the server, so the method will return succcessfully but no trophy will have been awarded. Thus, you should be careful not to misspell your trophy identifier in your code or in the associated trophy source item.
Note: Clients may award trophies to the current player. Server agents do not have a current player and therefore must pass in a valid player id.
Parametersident:String — the id of the player to award the trophy to
|
|
playerId:int |
Boolean — true if the trophy was awarded, false if the player already has that trophy.
|
getCookie | () | method |
public function getCookie(callback:Function, occupantId:int):void
Get the user-specific game data for the specified occupant. The first time this is requested per game instance it will be retrieved from the database. After that, it will be returned from memory.
Parameterscallback:Function — the function that will be called when the cookie has loaded.
The callback should be of the form:
function onGotUserCookie (cookie :Object, occupantId :int) :void { // read cookie } |
|
occupantId:int |
getPartyId | () | method |
public function getPartyId(occupantId:int):int
Get the specified player's partyId, or 0 if they're not in a party.
ParametersoccupantId:int |
int |
getPlayerItemPacks | () | method |
public function getPlayerItemPacks(playerId:int):Array
Returns all item packs owned by this client's player (the default) or a specified player. The packs are returned as an array of objects with the following properties:
ident - string identifier of item pack name - human readable name of item pack mediaURL - URL for item pack content count - the number of copies of this item pack owned by this player
Note: Clients may only get the item packs of the current player. Server agents do not have a current player and therefore must pass in a valid player id.
ParametersplayerId:int — the id of the player whose item packs to get
|
Array |
getPlayerLevelPacks | () | method |
public function getPlayerLevelPacks(playerId:int):Array
Returns all level packs owned by this client's player (the default) or a specified player. The packs are returned as an array of objects with the following properties:
ident - string identifier of item pack name - human readable name of item pack mediaURL - URL for item pack content premium - boolean indicating that content is premium or not
Note: Clients may only get the level packs of the current player. Server agents do not have a current player and therefore must pass in a valid player id.
ParametersplayerId:int — the id of the player whose level packs to get
|
Array |
holdsTrophy | () | method |
public function holdsTrophy(ident:String, playerId:int):Boolean
Returns true if this client's player (the default) or a specified player has the trophy with the specified identifier.
Note: Clients may only test the trophies of the current player. Server agents do not have a current player and therefore must pass in a valid player id.
Parametersident:String — the id of the player whose trophies to test
|
|
playerId:int |
Boolean |
isRegistered | () | method |
public function isRegistered():Boolean
Returns true if this player is a full registered member of Whirled, false if they are an anonymous guest. Games that wish to grant additional functionality to fully-registered members thereby encouraging guests to register for Whirled are themselves encouraged!
Note: this will always return false in the test environment.
ReturnsBoolean |
requestConsumeItemPack | () | method |
public function requestConsumeItemPack(ident:String, msg:String):Boolean
Requests to consume the specified item pack. The player must currently own at least one copy of the item pack. This will display a standard dialog asking the player if they wish to consume the pack.
If the player accepts the request to consume the item pack, a GameContentEvent.PLAYER_CONTENT_CONSUMED event will be dispatched on this control (on both the client and server).
Note: this method may only be called on the client. It will always return false on the server.
Parametersident:String — the identifier of the item pack to be consumed.
|
|
msg:String — a message to display in the dialog to help the player understand what's going on.
|
Boolean — true if the dialog was shown, false if the dialog was not shown because the player
is known not to own at least one copy of the item pack.
|
setCookie | () | method |
public function setCookie(cookie:Object, occupantId:int):Boolean
Store persistent data that can later be retrieved by an instance of this game. The maximum size of this data is 4096 bytes AFTER AMF3 encoding.
Note: Clients may only set the cookie of the current player. Server agents do not have a current player and therefore must pass in a valid player id.
Parameterscookie:Object — the id of the player whose cookie to get
|
|
occupantId:int |
Boolean — false if the cookie could not be encoded to 4096 bytes or less; true if the cookie
is going to try to be saved. There is no guarantee it will be saved and no way to find out
if it failed, but if it fails it will be because the shit hit the fan so hard that there's
nothing you can do anyway.
|
CoinsAwarded | event |
com.whirled.game.CoinsAwardedEvent
com.whirled.game.CoinsAwardedEvent.COINS_AWARDED
Dispatched when this player has been awarded coins.
An event type dispatched at the end of a game (before GAME_ENDED) to inform the game that the player has earned coins.
PlayerContentAdded | event |
com.whirled.game.GameContentEvent
com.whirled.game.GameContentEvent.PLAYER_CONTENT_ADDED
Dispatched when this player has purchased new game content.
Indicates that the a player has purchased new game content.
PlayerContentConsumed | event |
com.whirled.game.GameContentEvent
com.whirled.game.GameContentEvent.PLAYER_CONTENT_CONSUMED
Dispatched when this player has consumed an item pack.
Indicates that the a player has consumed an item pack. contentType() for this event will always be ITEM_PACK.
CURRENT_USER | constant |
public static const CURRENT_USER:int = 0
ID constant passed to cookie, prize and trophy functions to refer to the current player. On normal flash clients, this is used as a default value and should not be changed. On server agents, a valid playerId must be provided since there is no current player.
See also