Recent posts by tapir on Kongregate

Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

haha,
ok, it is shown now, by select the “Display in leaderboards”
really didn’t know and notice this option.

Thanks!

 
Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

After this discussion, I’m more confused than before starting this discussion. :(

 
Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

The Game class is the Document Class.
The output traces are exactly as what your said:


[QuickKong] connectToKong()
[QuickKong] loadedAPI()
[QuickKong] Kong API Successfully loaded and extracted. Shadow Services alert should appear for local testing
[OnMouseDown] mKongApiInited = true
[OnMouseDown] mFakeScore = 1
[OnMouseDown] QuickKong.stats = [object StatServices]
[OnMouseDown] mKongApiInited = true
[OnMouseDown] mFakeScore = 2
[OnMouseDown] QuickKong.stats = [object StatServices]

The zip file I posted above contains the released swf file, you can try to upload it in your account to check if the HighScore tab will be shown.

For this is just a test, it is not suitable to publish it to receive more players. Once it is published, no ways to remove it.

I remember, long long ago, the HighScore tab was ever shown in the preview page, even if the stat is submitted only once. If the HighScore needs many scores to show, I think Kongregate really should tweak it.

 
Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

I write a simple program to use QuickKong
Click to submit score.
Ok, api.services is not null. But the HighScore tab is still not shown.
You can try it by yourself, please remember to add two stats: HighScore and Test before testing it.
You can download the project zip file here: http://www.colorinfection.com/TestQuickKong.zip

package
{
   import flash.display.Sprite;
   import flash.text.TextField;
   import flash.events.Event;
   import flash.events.MouseEvent;
   
   public class Game extends Sprite 
   {
      private var mTextField:TextField = new TextField ();

      public function Game ()
      {
         mTextField.textColor = 0xFFFFFF;
         mTextField.width = 250;
         mTextField.height = 500;
         addChild (mTextField);
         
         addEventListener(Event.ADDED_TO_STAGE , OnAddedToStage);
      }
      
      private function OnAddedToStage (event:Event):void
      {
         stage.addEventListener (MouseEvent.MOUSE_DOWN, OnMouseDown);
         
         mTextField.appendText ("Initizing ...\n");

         QuickKong.connectToKong (stage, OnKongApiInited);
      }
      
      private var mKongApiInited:Boolean = false;
      private function OnKongApiInited ():void
      {
         mKongApiInited = true;
         
         mTextField.appendText ("Initized!\n");
      }
      
      private var mFakeScore:int = 0;
      private function OnMouseDown (event:MouseEvent):void
      {
trace ("[OnMouseDown] mKongApiInited = " + mKongApiInited);

         if (mKongApiInited)
         {
            ++ mFakeScore;
            
            mTextField.appendText (QuickKong.services.getUsername());
            mTextField.appendText ("> to submit score: ");
            mTextField.appendText (mFakeScore.toString ());
            
trace ("[OnMouseDown] mFakeScore = " + mFakeScore);
trace ("[OnMouseDown] QuickKong.stats = " + QuickKong.stats);

            QuickKong.stats.submit ("Test", mFakeScore);
            QuickKong.stats.submit ("HighScore", mFakeScore);
            
            mTextField.appendText (" [done]\n");
         }
      }
   }
}
 
Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

I just downloaded one the my old games and uploaded it as an unpublished game.
The high score tab is also not shown in the preview page.
Messed up. :(

 
Flag Post

Topic: Kongregate APIs / Can developers see the HighScore tab in the preview page?

?

 
Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

I just rebuilt one of my old games, which uses the swc method.
But the kongregate high score API in it also doesn’t work now.
Totally have no ideas now.

 
Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

Ok, I tried the QuickKong and retried my first method.
They both throw an error at:


api.services.connect();

By adding some traces, I found:
1. api is not null
2. api.hasOwnProperty (“services”)
3. api.services is null !!!

So strange!

 
Flag Post

Topic: Kongregate APIs / Really don't know why API doesn't work

I tried the both two methods: loading swf from web and using swc.

For the loading swf method, I do:

   private function InitKongregateAPI ():void 
   {
      var paramObj:Object = LoaderInfo(stage.loaderInfo).parameters; 
      var apiPath:String = paramObj.api_path || "http://www.kongregate.com/flash/API_AS3_Local.swf"; 
      Security.allowDomain(apiPath); 
      var request:URLRequest = new URLRequest (apiPath); 
      var loader:Loader = new Loader(); 
      loader.contentLoaderInfo.addEventListener (Event.COMPLETE, OnKongregateApiLoadComplete); 
      loader.load (request);
      stage.addChild (loader);
   }
   
   private var mKongregate:Object = null; 
   private function OnKongregateApiLoadComplete( event:Event ):void 
   {
      event.currentTarget.removeEventListener(Event.COMPLETE, OnKongregateApiLoadComplete);
      
      mKongregate = event.target.content;
trace ("kong API loaded: mKongregate = " + mKongregate); // this one is traced out
      mKongregate.services.connect();
      mKongregate.user.getPlayerInfo (OnKongregateGetUserInfo);
   }
   
   private function OnKongregateGetUserInfo ( playerData:Object ):void
   {
      trace ("isGuest: "+ playerData.isGuest); // this one is never traced out. strange!
   }
   
   private function SubmitStat (name:String, value:Number):void
   {
      mKongregate.stats.submit (name, value);
      
trace (“submitted.”); // this is traced out, but refresh the game page on Kongregate, no HighScore tab shown
   }

For the swc method:

   import com.kongregate.as3.client.KongregateAPI; 
   import com.kongregate.as3.client.events.KongregateEvent;
   
   private function InitKongregateAPI ():void
   {
      var kongregate:KongregateAPI = new KongregateAPI();
      kongregate.addEventListener (KongregateEvent.COMPLETE, OnKongregateApiLoadComplete2);
      stage.addChild (kongregate);
   }
   
   private function OnKongregateApiLoadComplete2 ( e:KongregateEvent ):void
   {
      trace (“kongregate API inited”); // this is traced out
      var kongregate:KongregateAPI = KongregateAPI.getInstance();
      kongregate.user.getPlayerInfo (OnKongregateGetUserInfo); 
   }

   private function OnKongregateGetUserInfo ( playerData:Object ):void
   { 
      trace ("222 isGuest: "+ playerData.isGuest); // this is also traced out, false.
   }
   
   private function SubmitStat (name:String, value:Number):void
   {
      var kongregate:KongregateAPI = KongregateAPI.getInstance();
      kongregate.user.getPlayerInfo (OnKongregateGetUserInfo);
      
      trace ("user name: " + kongregate.user.getName ()); // my user name is traced out
      kongregate.stats.submit (key, value);

      // no errors, but refresh the game page on Kongregate, still no HighScore tab shown
   }

Very frustrated, don’t know what is wrong in the code. The second method was ever successful in my old games.

 
Flag Post

Topic: Game Programming / [resolved] Help, problem when use both kong api and mochiads encryption

I have resolved it. The container to add the KongregateAPI object must be the stage object.

 
Flag Post

Topic: Game Programming / [resolved] Help, problem when use both kong api and mochiads encryption

sorry the text format.

 
Flag Post

Topic: Game Programming / [resolved] Help, problem when use both kong api and mochiads encryption

my game code for initializing kongregate api
if (domain == “kongregate.com” || domain == “congregate.com”)
{
trace (“Is kongregate or congregate”);

sIsKongregate = true; var kongregate:KongregateAPI = new KongregateAPI(); kongregate.addEventListener ( KongregateEvent.COMPLETE, Kongregate_OnInitComplete ); container.addChild ( kongregate ); trace (“kongregate api inited”);

}

If I don’t use mochi encryption, the output is:
kongregate or congregate
kongregate api inited

If I use mochi encryption, the output ios:
kongregate or congregate
Alert: Kongregate API could not be loaded, due to local testing. API will load when the game is uploaded.
>>> Kongregate Shadow Services instantiated for local development..
kongregate api inited

I use the .swc method to include kongregate api.

The code is same as that in my last game. That game works well.

 
Flag Post

Topic: Kongregate / Suggestions

How can I know who favorite my games?