问题描述
我刚刚开始尝试Haxe来制作一个Web应用程序,我想使用CreateJS,它具有一个Haxe extern lib东西。我将FlashDevelop用作IDE。
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.
因此,我在FlashDevelop中创建了一个新的Haxe JS项目,并使用 haxelib install createjs安装了CreateJS。现在,我试图将导入添加到Main.hx中,但是它不起作用。我的导入看起来像: import createjs.easeljs.Ticker; (从示例中了解到,只是复制了它,但是没有用:s)我还向项目添加了新的映射 lib,在其中添加了createjs内容。
So I created a new Haxe JS project in FlashDevelop, and installed CreateJS with "haxelib install createjs". Thougg now I try to add an import to my Main.hx, but it doesn't work. My import looks like: "import createjs.easeljs.Ticker;" (got that from an example, just copied it but didn't work :s) I also added a new map "lib" to my project, in which I added the createjs stuff.
我得到的错误是:src / Main.hx:3:字符0-31:找不到类:createjs.easeljs.Ticker
The error I get is: src/Main.hx:3: characters 0-31 : Class not found : createjs.easeljs.Ticker
我需要做的其他事情
谢谢!
-帕勃罗
推荐答案
的通常工作方式是:
-
您手动添加了原始Javascript *。在您的情况下,您可以将指向CreateJS javascript的标记添加到HTML文件中。
You include the original Javascript manually*. In your case, you add the tags pointing to the CreateJS javascript ( into your HTML file.
使用 extern文件是为了让Haxe知道其他文件在那里,并且知道可以调用什么方法,更改了属性等。它还有助于保持自动完成功能的完整和有用。
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.
如果外部被保存在一个库中,您需要安装该库( haxelib install createjs
),然后需要将该库包含在您的版本中,我通过添加 -lib createjs
到hxml构建文件中,Flash Develop可以通过打开 Project-> Properties-> Compiler Options
和将 createjs添加到库列表中。
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.
在Haxe文件中,就像上面一样,使用 include语句。
In your Haxe file, you use the "include" statements, like you have above.
从上面的描述中,我认为您缺少包含库的第3步,我不是Flash开发用户,所以我不确定是否完全不同,但是看起来在后续回答中,您已经从 createjs haxelib复制了一些* .hx文件,足以使其进行编译。但是,如果将'-lib createjs'行添加到hxml构建文件中,则不再需要这些。
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.
(*)例外是某些库包含Javascript。一个例子是当您在Haxe标准库中使用js.JQuery时-这包括为您提供的原始javascript。
(*) 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.
(编辑:感谢注释,增加了在Flash Develop中添加库的说明)
( added instructions for adding libraries in Flash Develop thanks to comment)
这篇关于FlashDevelop,Haxe导入CreateJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!