Question about Flash Extension [QUESTION]

kiwixoats

  • Posts: 104
I downloaded a leaderboard system SDK (its a SWC) and like the instructions said, I extracted the SWF from it and this is what my extension looks like (see attachment #1). Yes, it's enabled in my game.

However, when I try to use the API code directly in the game, it gives me these errors:
Code: [Select]
Scores Button (54) -  Unexpected <
Scores Button (54) -  Unexpected <
Scores Button (54) -  Unexpected <
Scores Button (54) -  Unexpected <

It's coming from this API code I called (its AS3):
Code: [Select]
//Load scores
Blocked.loadScores("blocked", TimeScope.ALL_TIME,
                function onComplete(scores:Vector.<Score>):void {
                    trace("retrieved " + scores.length + " scores");
                }, function onError(error:String):void {
                    trace("error loading scores: " + error);
                });
(also see attachment #2)

And If I change Vector.<Score> into haxe (which becomes Array<Score>), it gives me other errors like unexpected { and stuff like that. And if I change those, it'll give me another error like Unknown identifier.

Question #1: Do I have to convert the AS3 code snippets I placed inside the game into haxe?

Question #2: If not, what's going on?

« Last Edit: March 24, 2014, 11:14:17 am by Jon »

captaincomic

  • *
  • Posts: 6108
I think what you have to do is to add the AS3 code in an engine extension http://community.stencyl.com/index.php/topic,14985.0.html
Then you can call it with haXe code, or you can add blocks in the extension.

kiwixoats

  • Posts: 104
I think what you have to do is to add the AS3 code in an engine extension http://community.stencyl.com/index.php/topic,14985.0.html
Then you can call it with haXe code, or you can add blocks in the extension.

But the AS3 code I'm calling is from the library.swf (the leaderboard api), so it's already an extension.

This is what I'm trying to achieve:
Quote
Rename/Edit TestFlash.hx to meet your needs. If you don’t want or need a source file, you can safely delete it and call the SWF’s stuff directly from the game.
as Jon said.

But are you trying to say this?:

*my engine extension is AS3
*i have to call it in the game using haxe (right now I'm calling it using AS3)

captaincomic

  • *
  • Posts: 6108
If you already made an extension for the library.swf, then you need to call it with haxe.

I think this should work (just uppercase Void, and Array<Score> instead of Vector.Score)
Code: [Select]
Blocked.loadScores("blocked", TimeScope.ALL_TIME,
                function onComplete(scores:Array<Score>):Void {
                    trace("retrieved " + scores.length + " scores");
                }, function onError(error:String):Void {
                    trace("error loading scores: " + error);
                });
You probably need some imports as well for Blocked and TimeScope.

kiwixoats

  • Posts: 104
If you already made an extension for the library.swf, then you need to call it with haxe.

I think this should work (just uppercase Void, and Array<Score> instead of Vector.Score)
Code: [Select]
Blocked.loadScores("blocked", TimeScope.ALL_TIME,
                function onComplete(scores:Array<Score>):Void {
                    trace("retrieved " + scores.length + " scores");
                }, function onError(error:String):Void {
                    trace("error loading scores: " + error);
                });
You probably need some imports as well for Blocked and TimeScope.

Ok I'm trying to import the package and its classes but it says class not found and it just gives me random errors.

Ah whatever, thanks for your help anyway.

**EDIT: I don't see what I'm doing wrong. I tried it in Flash and it worked, I tried a different API in Stencyl and it also worked, but this API doesn't seem to work.

« Last Edit: January 07, 2013, 10:44:46 pm by kiwixoats »

captaincomic

  • *
  • Posts: 6108
Hm, I don't know either, haven't worked with extensions yet. Did you manage to import the classes of the other API?

kiwixoats

  • Posts: 104
Hm, I don't know either, haven't worked with extensions yet. Did you manage to import the classes of the other API?

Strangely enough I tried 3 different API, 2 swf libraries and 1 .hx type, with the following results:
The class imported correctly for 1 of the swfs
But the other 2 APIs had problems importing -- specifically the classes were not being found even though I was placing the library/.hx in the same folder. However, when I moved the .hx for 1 of the APIs outside the extension folder and into its own folder, it started importing correctly. I think this might've had to do with the classpath inside the include of that extension. Nevertheless, I still don't know how to import the classes correctly when they're in the same folder as the extension because it says they're not found. I have to experiment a little more with this classpath stuff.

**EDIT: I see that for 1 swf api that was not working, when I finally accessed the classes, testing the game gave me a big white swf. So I don't think its API is suitable for stencyl.

« Last Edit: January 08, 2013, 01:38:50 pm by kiwixoats »