gpt4 book ai didi

javascript - Haxe - 找不到类 : Main

转载 作者:行者123 更新时间:2023-11-30 10:25:39 25 4
gpt4 key购买 nike

我第一次尝试使用 haxe 和 cocktail。我遵循本教程:http://www.silexlabs.org/haxe/cocktail/tutorials/getting-started-with-cocktail/

主.hx

import js.Lib;
import js.Dom;

class Main
{
static inline var ICON_COCKTAIL_PATH:String = "assets/icone_cocktail_blanche_ombre.png";
static inline var ICON_HAXE_PATH:String = "assets/icone_haxe_blanche_ombre.png";

static function main()
{
#if !js
//init cocktail and load the "index.html" file in the bin folder
cocktail.api.Cocktail.boot();
#end

//html and css loaded
Lib.window.onload = function(e) new Main();
}

public function new()
{
// get the image node
var image:Image = cast Lib.document.getElementById("icon");

// create interactivity
image.onmouseup = function(event:Event) {
// if image source is cocktail icon, change it to Haxe one
if (image.src.indexOf(ICON_COCKTAIL_PATH) != -1)
image.src = ICON_HAXE_PATH;
// if image source is not cocktail icon, change it back to cocktail
else
image.src = ICON_COCKTAIL_PATH;
}
}
}

编译.hxml

-main Main
-cp ../src
-js ../bin/Main.js

我有以下文件夹结构:

\Helloworld
\bin
\assets
\icone_cocktail_blanche_ombre.png
\icone_haxe_blanche_ombre.png
\app.css
\build
\src
\index.html
\Main.hx
\compile-js.hxml

但是当我尝试编译时:

haxe compile.hxml 
Class not found : Main

谢谢

最佳答案

我认为您的 compile.hxml 应该如下所示。记下 src 文件夹的路径。我相信这与 hxml 文件位置有关。

-main Main
-cp src
-js bin/Main.js

关于javascript - Haxe - 找不到类 : Main,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19682649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com