0

I have a haxe library that I need to compile to JS and AS3. I already have the JS part working fine and can use the exported code as is within node.js. However I have the following problem when compiling to AS-3. The haxe compiler includes the haxe standard library and generates AS3 classes in a default package:

package  {
    import flash.Boot;
    public class List {
    ...

Now the problem is that I get a ton of ambiguous reference errors:

Error:(101, 0)  Ambiguous reference to List

In this case the List class conflicts with the List which is defined as part of the Feathers (Starling) library.

So far I have not found any solution. I was hoping for a compiler flag which could be used to set the default package name, but have not found anything so far.

** EDIT **

The errors while compiling the feathers source which I include in my project. I do not want to modify the feathers source code.

/Users/santiago/Documents/source/frameworks/Feathers/source/feathers/controls/renderers/DefaultListItemRenderer.as
Error:(200, 0) [lib (module cuarenta-lib)]: Ambiguous reference to List
Error:(202, 0) [lib (module cuarenta-lib)]: Ambiguous reference to List
Error:(208, 0) [lib (module cuarenta-lib)]: Ambiguous reference to List
Error:(222, 0) [lib (module cuarenta-lib)]: Ambiguous reference to List 

Thanks!

santiagoIT
  • 9,411
  • 6
  • 46
  • 57
  • So the Starling `List` is in a specific package, your `List` is in the default package, and you can't figure out how to specify between them in AS3 in situations where you have the Starling version imported? – JKillian Jul 19 '14 at 00:03
  • @JKillian please refer to the edit – santiagoIT Jul 19 '14 at 00:14
  • Ah, I got you. So your `List` class in the top-level package is messing up the Feathers source. Hmmm, easiest solution might just be to rename your `List` class. – JKillian Jul 19 '14 at 00:16
  • Wanted to mention that there is a `--remap` option of the haxe compiler to rename packages, but I don't think it will help in this case – JKillian Jul 20 '14 at 02:04

2 Answers2

0

Edit: This answer doesn't make sense because the List class is part of the Haxe standard library. I'm leaving it here for clarity.

Two dirty but easy and effective solutions.

  • Rename your List class to something else.
  • Put the Haxe version of your List class in a haxe package. Then when it generates the AS3 code it will be in an AS3 package and you won't get those ambiguous reference errors, because the feathers library won't be importing your new package with your List class.
JKillian
  • 18,061
  • 8
  • 41
  • 74
  • It is not my List class. That class belongs to the Haxe Standard Library. It is included automatically. How would I include it inside a specific Haxe Package? – santiagoIT Jul 19 '14 at 01:31
  • Ugh, sorry, should have been able to tell that from your question - my apologies. Have you tried compiling straight to a .swf instead of to AS3 source? I doubt that would help just personally curious if it's any different. You could bundle Feathers as a .swc and include it with the -swf-lib option of the haxe compiler – JKillian Jul 19 '14 at 01:34
  • Yes there is no difference if I use a swc or the as3 source directly. I would like to continue using the feathers Source Code directly as it is a clone of the github repo – santiagoIT Jul 19 '14 at 01:39
  • Let me know if you come up with a solution. If you use a nice IDE like FlashDevelop, you'll at least be able to refactor the Feathers List class to a new name real easily until there's a better solution I guess – JKillian Jul 20 '14 at 02:03
0

To move just a single Class to another class and avoid conflict you can use the @:native metadata.

Add the following to the compiler call to rename List to hx.List:

--macro addMetadata('@:native("hx.List")', 'List')
Bruno Santos
  • 101
  • 4