How add this api to my game??

Frozennnn

  • Posts: 83
Hi i have this api in .as i need to add in my game but when i create a freeform code and replace with this code i get  error

Kiz10API:  Missing ;
   line: 1
   columns: 12-17


Code: [Select]
package com.kiz10 {

    import flash.display.Loader;
    import flash.events.IOErrorEvent;
    import flash.errors.IOError;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.system.Security;

    public class Kiz10API
    {
        public static var api:Object;
        public static var apiLoaded:Boolean = false;
       
        private static const API_URL:String = "http://kiz10.com/applications/controllers/Kiz10API.swf";
        private static var init_callback:Function;
        private static var apiLoader:Loader;
       
        private static var id_game:int;
        private static var api_key:String;
       
        public static function init(idGame:int, apiKey:String, callback:Function = null):void {
            id_game = idGame;
            api_key = apiKey;
            init_callback = callback;
           
            Security.allowDomain(API_URL);
            apiLoader = new Loader();
            apiLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onInitLoadComplete, false, 0, true);
            apiLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onInitError, false, 0, true);
            apiLoader.load(new URLRequest(API_URL));
        }
       
        private static function onInitError(e:IOError):void {
            apiLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onInitLoadComplete);
            apiLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onInitError);
            if (init_callback != null) {
                init_callback( { success:false, responseCode:"IO_ERROR", data:null } );
            }
        }
       
        private static function onInitLoadComplete(e:Event):void {
            apiLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onInitLoadComplete);
            apiLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, onInitError);
            api = e.target.content;
            api.init(id_game, api_key);
            apiLoaded = true;
            if (init_callback != null) {
                init_callback({ success:true, responseCode:"OK", data:null });
            }
        }
       
        public static function submitStat(stat:String, value:int):void {
            if (apiLoaded) {
                api.submitStat(stat, value);
            }
        }
       
        public static function submitAchievProgress(achievement:String, progress:int):void {
            if (apiLoaded) {
                api.submitAchievProgress(achievement, progress);
            }
        }
       
    }

}

mdotedot

  • Posts: 1569
Hello Frozennnn,

At least what you need to do is to remove the package com.kiz10 { line and the last }
You might need to put the imports in a different place, but first start with removing the package.

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Frozennnn

  • Posts: 83
Hi
I get this errors now

Source/scripts/Kiz10API.hx:15: characters 23-28 : Unexpected const

Source/scripts/Kiz10API.hx:19: characters 35-38 : Type name should start with an uppercase letter

mdotedot

  • Posts: 1569
Hi Frozennn,

Please join me in the chat to work through this, because I would expect more and more errors :)

const => replace const with var

I will try to see if I can get the code to work. Do you have any other source files or is the posted code the thing you have?

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

mdotedot

  • Posts: 1569
We chatted and I attempted to convert the API.

I can't seem to convert the loaded SWF into a MovieClip and call the functions inside it.

Here is the code: https://dl.dropboxusercontent.com/u/107982821/stencyl/Kiz10API.png

To call I used an import:
Code: [Select]
import com.kiz10.Kiz10API;

Click event advanced code
Code: [Select]
trace("Calling kiz10api");
Kiz10API.init(0,"THIS IS THE API KEY ", function(){setGameAttribute("debug"," inside callback : State of API-Call ");});
Kiz10API.submitStat("a",10);

And in draw event I showed the game attributes but it only loads the SWF and doesn't convert it into a MovieClip or at least not a movieclip with the code intact.

I fear that we only can load flash movies instead of real code but I'm not familiar enough with actionscript to be sure ..

Hopefully someone else with more knowledge between flash and haxe can help us out!

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Frozennnn

  • Posts: 83
Hi thanks i will keep checking

Demkamen

  • Posts: 124
Hi guys.. you could integrate kiz10 api?

rob1221

  • *
  • Posts: 9448
Well mdotedot didn't figure it out and he's pretty good with code. so the answer to your question is probably no.  I'm not saying it can't be done, just that you probably won't find the answer here if no one has the experience.  I also remember having problems with dynamically loaded SWFs for some other sponsorship API that I forgot the name of.  It's one of the reasons I gave up on Flash sponsorship completely.

Kazetoon

  • *
  • Posts: 556
Was anyone able to get it working? If not did you call the deal off?
Little Drop - Try it out!
     
iphone/ipad Android
Newgrounds Stencyl Arcade Kongregate
Developer Website


Kazetoon

  • *
  • Posts: 556
I did it yesterday)

Seriously? That would be great if you could tell us how. I might have him as a sponsor.
Little Drop - Try it out!
     
iphone/ipad Android
Newgrounds Stencyl Arcade Kongregate
Developer Website

Demkamen

  • Posts: 124
just add this resourse, and use this instruction http://kiz10.com/applications/controllers/instructions/api.php. If you want detailed instruction - my skype (demkamen).

Kazetoon

  • *
  • Posts: 556
Thanks a lot, will check this out if the deal happens.
Little Drop - Try it out!
     
iphone/ipad Android
Newgrounds Stencyl Arcade Kongregate
Developer Website