Game Development Reference
In-Depth Information
class, a Responder object is created for handling the returned data.
To make sure that the data being saved is valid and the service is
not being hacked, the method creates a date stamp and combines
it with the other pieces of data (including the secret key). This
value is then hashed twice using MD5. If you
re not familiar with
hashing, you can refer to the bonus online chapter on securing
your games, On Your Guard. Briefly, it is the process of taking a
chunk of data and reducing it algorithmically to a fixed length string
of numbers and letters. The goal is that it should be impossible or
nearly impossible for someone to be able to determine the original
data. MD5 is just one of many other algorithms, including a number
of them that are far more secure, such as SHA256. I chose MD5
because it is very fast to process and is a native part of PHP, a back-
end software that will perform a comparison hash to validate the data.
Once this hash value is created, a remote method is called via
the NetConnection, saveScore , which is part of the HighScores class
in the games package in the PHP code. This method accepts the
game ID, score, and the various pieces of validation data. Note that
we do not send the secret key
'
it will be up to the author of the
back-end service (in this case, me) to make sure I have the same
key in use there. Next, we will look at the code that executes when
loading the leaderboard screen.
public var btnBack:SimpleButton;
public var tfRank:TextField;
public var tfInitials:TextField;
public var tfScores:TextField;
public var tfStatusMessage:TextField;
public function Leaderboard()
{
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage,
false, 0, true);
}
private function onAddedToStage(e:Event):void
{
btnBack.addEventListener(MouseEvent.CLICK, onBack,
false, 0, true);
createConnection();
loadScores();
}
private function loadScores():void
{
var responder:Responder = new Responder(onScoresLoaded,
onScoresLoadedError);
Search Nedrilad ::




Custom Search