FlashDevelop, Haxe import CreateJS?

后端 未结 3 951
说谎
说谎 2021-01-20 02:18

I just started trying out Haxe to make a web-app, and I would like to use CreateJS, which has a Haxe extern lib thingy. I\'m using FlashDevelop as my IDE.

So I creat

相关标签:
3条回答
  • 2021-01-20 02:41

    Ok I played around a bit more with the maps and now it's fixed, here's how it looks now:

    enter image description here

    If anyone has some more info about externs, and how they work, this would still be appreciated!

    Thanks

    0 讨论(0)
  • 2021-01-20 02:48

    The way Haxe externs usually work is:

    1. You include the original Javascript manually*. In your case, you add the tags pointing to the CreateJS javascript ( into your HTML file.

    2. The 'extern' files are used so that Haxe knows the other files are there, and knows what methods can be called, properties changed etc. It also helps keep the auto-complete fully functional and useful.

    3. If the externs are kept in a library, you need to install that library (haxelib install createjs) and then you need to include that library in your build. I do this by adding -lib createjs to the hxml build file. Flash Develop can do this by opening Project->Properties->Compiler Options and adding "createjs" to the Libraries list.

    4. In your Haxe file, you use the "include" statements, like you have above.

    From your description above, I think you're missing the bit in step 3 where you include the library. I'm not a Flash Develop user, so I'm not sure if it's different at all, but it looks like in your follow up answer you've copied some of the *.hx files from the 'createjs' haxelib, just enough to make it compile. If you add the '-lib createjs' line to your hxml build file though, you shouldn't need these anymore.

    Hope this helps you get started, let me know if you get stuck and I'll try update my answer.

    (*) an exception to this is some libraries include the Javascript for you. An example is when you use js.JQuery in the Haxe standard library - this includes the raw javascript for you. Most libraries you'll have to add the scripts yourself though.

    (Edit: added instructions for adding libraries in Flash Develop thanks to comment)

    0 讨论(0)
  • 2021-01-20 03:07

    In FD goto Project->Properties then to the Compiler Options tab there you can add each required lib you installed with haxelib and don't need to copy the lib source into your project source tree. This will only be useful in case you need to modify the lib.

    0 讨论(0)
提交回复
热议问题