Genome2D + FGL API error HELP!

129 views
Skip to first unread message

2DGuy

unread,
Jan 31, 2014, 7:28:09 AM1/31/14
to haxe...@googlegroups.com
Long story short, the 2D stage3D framework "Genome2D" (written in Haxe) is throwing an error while using the FGL API for mobile developers. According to the developer of "Genome2D" it is an error due to the way Haxe is handling the stage when combined with the FGL API. The FGL API works with other stage3d frameworks like Starling, so we're assuming the problem lies within Haxe.

I would be most grateful if someone could test this FlashDevelop project, (I guess you would have to convert it to Haxe first?) and see if you can duplicate the error and possibly find out what is happening. The FGL API does launch the .swf in a container, so we think it could be related to that.

I've created a very small shell to test this. 100 lines of code, 100k download. ;) It's a FlashDevelop project. Hopefully it's' very easy to convert to Haxe and test.


Download the FGL API here:


Thank you in advance to anyone willing to give this a go. ;)

2DGuy

unread,
Jan 31, 2014, 7:31:04 AM1/31/14
to haxe...@googlegroups.com
This is the error being thrown btw...

TypeError: Error #1006: iterator is not a function.
at haxe.ds::StringMap/keys()
at com.genome2d.context::GStage3DContext/onContextInitialized()

Peter Stefcek

unread,
Jan 31, 2014, 9:23:25 AM1/31/14
to haxe...@googlegroups.com
Just to shed a little more light into the problem this is the exact line that throws an error which is outside of Genome2D scope as it seems to be a Map problem:

for (key in GTextureBase.g2d_references.keys()) {
     GTextureBase.g2d_references[key].invalidateNativeTexture(true);

2DGuy

unread,
Jan 31, 2014, 9:33:23 AM1/31/14
to haxe...@googlegroups.com
Thanks. FGL is taking a look into now as well. I'm fairly sure the problem lies with how they're attaching the game into their container api.

2DGuy

unread,
Jan 31, 2014, 11:40:46 AM1/31/14
to haxe...@googlegroups.com
The problem seems to stem from the fact that FGL is loading the game into an object already on the display list, so perhaps Haxe is looking for something that is not at the root level anymore. FGL responded by giving some example code that might help recognize the problem. (Syntax may not be correct, it was typed on the fly and is for representation only and is not ready to run.)

Btw..what does the 3rd parameter do?  p_contextClass:Class in the GContextConfig call do? I wonder if that could help?


package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.URLRequest;
public class LoaderTest extends Sprite
{
private var gameLoader:Loader
public function LoaderTest()
{
gameLoader = new Loader();
this.addChild(gameLoader);
gameLoader.load(new URLRequest("game.swf"));
}
}
}

2DGuy

unread,
Feb 1, 2014, 8:22:10 AM2/1/14
to haxe...@googlegroups.com
Just wanted to say I've given up on this. Thanks for those who looking into this.

Tarler

unread,
Feb 2, 2014, 6:10:30 PM2/2/14
to haxe...@googlegroups.com, davem...@gmail.com
Hi.
For what it's worth, this sounds similar to an issue I was having with Arrays in loaded SWFs
See the thread: Array.prototype magic not working in loaded SWF

Peter Stefcek

unread,
Feb 3, 2014, 7:30:15 AM2/3/14
to haxe...@googlegroups.com, davem...@gmail.com
Further investigation shows that this has something to do with static initialization. If you have static variables initialized like this:

static public var testMap:Map<String,Map> = new Map<String, Test>();

you will run into this error. So what I did was remove the static initialization and moved it into the constructor for it to check if the static var is initialized and if not initialize it. Can any Haxer point out if there may be other issues initialization inside external wrapper?

Peter Stefcek

unread,
Feb 3, 2014, 11:22:41 AM2/3/14
to haxe...@googlegroups.com, davem...@gmail.com
So no luck this "iterator is not a function" problem persists in other blocks of code that are not statically initialized. I searched for a similar problem and seems that many users have it, with Flex or with loading Haxe swcs in loader (for example http://haxe.org/forum/thread/1081) It seems like the Haxe stuff is not initialized properly although I do call haxe.initSwc(mc).

Guys it is a huge issue as it means haxe generated libraries using Maps can't be used insided a wrapped content which is pretty much any game portal.

Thanks.

Peter Stefcek

unread,
Feb 3, 2014, 3:59:38 PM2/3/14
to haxe...@googlegroups.com, davem...@gmail.com
So further research shows that this is thrown by the keys() function in StringMap. I was suspecting that haxe didn't intialize so there was no Array.prototype.iterator but this is not the issue as I can easily trace that to be a function before the other error occurs.

Peter Stefcek

unread,
Feb 3, 2014, 8:08:27 PM2/3/14
to haxe...@googlegroups.com, davem...@gmail.com
Ok another info. I have this block of code:

var a:Array<String> = untyped __keys__(dictionary);
trace(a);
trace((cast a).iterator));
trace(untyped __global__["Array"].prototype.iterator);

It outputs this inside standalone swf

[key1, key2...]
function Function() {} 
function Function() {}

Whereas inside the FGL wrapper the output is different:

[key1, key2...]
null
function Function() {}

Which clearly shows that the iterator function is not there even if the prototype function is defined, I am kind of confused atm, any info would be appreciated.

Thank you.

Justin Donaldson

unread,
Feb 3, 2014, 8:37:32 PM2/3/14
to Haxe, davem...@gmail.com
Is the array prototype getting overwritten/altered?  I know Haxe needs to modify it to add that iterator.

If that's true, I'd check and see if the modifications that Haxe and the FGL api are compatible.  If so, it seems like one approach would be to delay applying Haxe's "Boot" alterations so that they occur after FGL's. I'm not sure how to do it, although I bet it's possible.



--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/groups/opt_out.

Peter Stefcek

unread,
Feb 4, 2014, 5:20:59 AM2/4/14
to haxe...@googlegroups.com, davem...@gmail.com
Justin the question is why is the a.iterator null when there is actually a function on the Array.prototype.iterator defined? Even if it was overwritten by different function which I doubt it shouldn't be null for the a.iterator
Reply all
Reply to author
Forward
0 new messages