2010-02-06 3 views
2

kongregate를 사용하는 사용자가 있는지 확인하기 만하면됩니다. 그렇다면 문제가 있습니다.kongregate api에 연결

로컬로 디버깅 모드로 kongregate에 연결하면 정상적으로 작동합니다. 하지만 서버에 게임을 업로드하면 다음 오류가 발생합니다.

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() 

아래 코드는 내가 사용하는 코드입니다. 그리고 클래스 속성은 여기

// 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(); 
     } 

핸들러 아래

// 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... 
     } 

입니다

var isGuest:Boolean = kongregate.services.isGuest(); 
      var username:String = kongregate.services.getUsername(); 
      menu.MenuInfo.text = "Kongregate Edition\nWelcome, "+username; 
+0

nevermind. 문제는 loadComplete 이벤트가 finsihed되기 전에 메뉴에서 호출 되었기 때문입니다. – numerical25

답변

1

내가 그것을이 줄 수 있다고 생각 오류를 트리거 코드의 라인이 설정 :

var paramObj:Object = LoaderInfo(sr.loaderInfo).parameters; Kong은 자신의 동영상을 SWF로로드합니다. 매개 변수가 해당 수준에 존재하지 않을 수 있습니다. 봅니다 :

var paramObj:Object = LoaderInfo(root.loaderInfo).parameters; 

변화 나 매개 변수를 발견해야한다 기대 루트에 대한 참조입니다.

기타 : 오류 메시지의 내용을 게시 할 수 있습니까?

관련 문제