Juste vérifier pour voir si quelqu'un utilise kongregate. Si oui, j'ai des problèmes.se connecter à kongregate api
Lorsque je me connecte à kongregate localement en mode débogage, cela fonctionne très bien. mais quand je télécharge le jeu sur leurs serveurs, j'obtiens l'erreur suivante.
TypeError: Error #1010: A term is undefined and has no properties.
at com.objects::Engine/GameMenu()
at Function/http://adobe.com/AS3/2006/builtin::apply()
Voici le code que j'utilise. et les propriétés de la classe i mis
// Kongregate API reference
private var kongregate:*;
public function Engine(sr:Stage):void
{
// Pull the API path from the FlashVars
var paramObj:Object = LoaderInfo(sr.loaderInfo).parameters;
// The API path. The "shadow" API will load if testing locally.
var apiPath:String = paramObj.kongregate_api_path ||
"http://www.kongregate.com/flash/API_AS3_Local.swf";
// Allow the API access to this SWF
Security.allowDomain(apiPath);
// Load the API
var request:URLRequest = new URLRequest(apiPath);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.load(request);
this.addChild(loader);
var music:MusicBackGround = new MusicBackGround();
music.play(0,int.MAX_VALUE);
this.sr = sr;
init();
}
est ici le gestionnaire
// This function is called when loading is complete
function loadComplete(event:Event):void
{
// Save Kongregate API reference
kongregate = event.target.content;
// Connect to the back-end
kongregate.services.connect();
// You can now access the API via:
// kongregate.services
// kongregate.user
// kongregate.scores
// kongregate.stats
// etc...
}
ci-dessous est la ligne de code qui déclenche l'erreur
var isGuest:Boolean = kongregate.services.isGuest();
var username:String = kongregate.services.getUsername();
menu.MenuInfo.text = "Kongregate Edition\nWelcome, "+username;
rien ne va. le problème est dû au fait qu'il a appelé le menu avant que l'événement loadComplete ne soit terminé. – numerical25