Stencyl 3.4.0 is now out. Get it now!

Defined in this class error (first dive into creating an extension)

TheIndieStation

  • *
  • Posts: 2181
So my plans for my MobileGameKit is to wrap it up into a nice looking extension. The first 2 hours went flawless up till the point where I had created 2 custom blocks that simply printed something to the logviewer. Great!

Then I started to add a loop to my code which looked like a basic JS for loop (for var i = 0; i < 10; i++). This didn't work because it turns out in haXe you need to use an itterator, so I changed it to (for i in 0...10). But then I started to get an error that got my stuck for the past 2 hours. I have put my googling skills to the test, but coudn't really find a solution, nor an explenation about what it means other then something about an old haXe syntax. The problem is that even after I have removed everything back to the bare bones, I still keep getting that error, even when I removed my extension and started from scratch. So hopefully someone can point me into the right direction here!

The error:
https://gyazo.com/ce6d0a0034a814e725edf40eff40ef6d

The block I created and placed directly into a scene event (not a scene behavior) in a scene called "scene":
(this worked during the first 2 hours, so I went with that again)
https://gyazo.com/a2050d7b6d95c77f6eec801aaaba8ae7

Code preview of that scene event:
https://gyazo.com/8585de53782b3f0a6652d838f3bbe4e8

Blocks.xml:
https://gyazo.com/6d0daf86ee54fee4d850735f1660d75d

MobileGameKit.hx:
https://gyazo.com/f916a18bc33c5907171ed59eed43a14c

Folder structure:
https://gyazo.com/ca22bf4761dd809df96795b6c53d3022

The little bit of info I already found myself on this error:
http://old.haxe.org/manual/haxe3/migration

More specificly:
https://gyazo.com/de384d89172f179c2a56b3b46da0d04e

All info is welcome!

greatanthony

  • Posts: 129
i'm not expert :) , but in my case I too found "defined in this class " error.....checking the logviewer's top 5 lines contained the actual error of my extension (atleast this was solution of my problem)
My error was that i didn't gave any return type, [  Public static function mytest.print( s: string, 2 : Int) : void]
I didn't provided the return type ( void on my case) at the end of the function line..

merrak

  • *
  • Posts: 1488
What does the rest of the log say? Were there more compilation errors?

TheIndieStation

  • *
  • Posts: 2181
pardon me for the long wait, I never got a notification of your replies!
This is the only thing I can find related to my extension in the logs:

Code: [Select]
2017-06-25 18:18:10,662 ERROR [Thread-353] stencyl.sw.io.write.resource.HXWriter: Compilation error in behavior: Events for 'scene': Defined in this class
2017-06-25 18:18:10,662 ERROR [Thread-353] stencyl.sw.util.StreamGobbler: [haxelib] Source/scripts/SceneEvents_0.hx:73: lines 73-95 : Defined in this class

@greatanthone where did you placed this:
Code: [Select]
Public static function mytest.print( s: string, 2 : Int) : voidBecause if I look at the labels extension, I don't see this format anywhere.

SadiQ

  • Posts: 1720
Look into the games-generated folder for your game, then look into the Source/scripts/ folder and in there you'll find the SceneEvents_0.hx file. Line 73 should contain the error (or it should be around that line anyway).
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

TheIndieStation

  • *
  • Posts: 2181
Already put that code in the original post

Code preview of that scene event:
https://gyazo.com/8585de53782b3f0a6652d838f3bbe4e8

merrak

  • *
  • Posts: 1488
Quote
even when I removed my extension and started from scratch

I didn't catch that when I first read the post, but that is definitely odd. Do you have a sample .stencyl project export?

TheIndieStation

  • *
  • Posts: 2181
Here is the extension itself. You can just create a new empty project to use it in. The problem must be somewhere in the extension since the game compiles just fine when not using my extension block (that currently only prints something to the log).

greatanthony

  • Posts: 129
Hi there :) , Downloaded the extension and tested....

I was right ,  The error was in top 5 lines....( actually on 4th)


.....as of my research in this sleepy night here.....
Whichever codewriter is used (flashdev, notepad,etc) it does not originally have any variable of type : ACTOR or ACTOR TYPE..

But on looking the "Label Extension"...it is done using
Code: [Select]
import com.stencyl.models.Actor; in the haxe file of it....
And since in xml, originally Actor and Actor Type are supported for stencyl, so  there's no issue afteron....

So the only thing is that the .Hx file needs to know from where it can understand the "Actor" or "Actor Type"
I think here, since Actor Type is used,   
Code: [Select]
import com.stencyl.models.actor.ActorType; should work .....

---That's all i looked for  :) ....Pardon me If there is any other actual error that is causing the problem.....
Anthony



greatanthony

  • Posts: 129
Good News, 

I tested and it works Fine !!!!!   

It prints the line to HUD console :
Here's a screenshot:


The Modified haxe file now is :
Code: [Select]
import com.stencyl.models.actor.ActorType;

class MobileGameKit
{
public static function CreateThumbstick(mActorType:ActorType, mLocation:Int, mDirectionLock:Int)
{
trace("created thumbstick at position: "+mLocation+" with directionlock: "+mDirectionLock);
}
}
Only that new Import line  :)  And no change to the whole extension ....
 

I Have also attached that  modified Haxe File.....


TheIndieStation

  • *
  • Posts: 2181
This is very odd, since I never added that on my first try when it all worked..?
Thanks nontheless!