Game Development Reference
In-Depth Information
5. Next, we create the LoadXMLData(string : String) funcion, which will parse
the XML string data that returns from the server. We will type this script after the
GetScores() funcion as follows:
//Parse the XML data from the server
public function LoadXMLData(string : String) : void {
XMLParser.Parse(string);
b_loaded = true;
Debug.Log(string);
}
6. Next, type the rest of the code as follows:
//Getting User length
public function GetUserLength() : int {
if (XMLParser != null) {
return XMLParser.UserLength();
} else {
return 0;
}
}
//Getting User Name by index
public function GetNameData(index : int) : String {
if (XMLParser != null) {
return XMLParser.Name(index);
} else {
return "";
}
}
//Getting User Score by index
public function GetScoreData(index : int) : int {
if (XMLParser != null) {
return XMLParser.Score(index);
} else {
return 0;
}
}
//Loaded XML
public function IsLoaded() : boolean {
return b_loaded;
}
The preceding funcions get the server data from the XMLParser (where we stored
users' data that returns from the server).
 
Search WWH ::




Custom Search