未捕获的ReferenceError:Haxe-js项目中未定义$hxClasses
Uncaught ReferenceError: $hxClasses is not defined in Haxe js project
我在Haxe IRC频道上讨论过一个问题,但无法解决。这似乎是编译器的一个错误。
这是Haxe代码:
package;
import js.Lib;
import js.three.Three;
import haxe.Timer;
class Main {
public var timer:Timer;
public var renderer:WebGLRenderer;
public var scene:Scene;
public var camera:PerspectiveCamera;
public function new() {
timer = new Timer(30);
var w = Lib.window.innerWidth;
var h = Lib.window.innerHeight;
scene = new Scene();
// create a red cube
var material = new MeshLambertMaterial({color:0xff0000});
var geometry = new CubeGeometry(50, 50, 50, 1, 1, 1, material, null);
var cube = new Mesh(geometry, new MeshFaceMaterial());
cube.position.set(0, 100, 0);
scene.add(cube);
// add some light
var pointLight = new PointLight(0xffffff, 1, 0);
pointLight.position.set(10, 50, 130);
scene.add(pointLight);
// and a camera
camera = new PerspectiveCamera(70, w/h, 1, 1000);
camera.position.z = 500;
scene.add(camera);
// setup renderer in the document
renderer = new WebGLRenderer(null);
renderer.setSize(w, h);
Lib.document.body.appendChild(renderer.domElement);
untyped Lib.window.onload = onLoad;
}
public function onLoad() {
timer.run = function(){
renderer.render(scene, camera, null, null);
}
}
public static function main() {
new Main();
}
}
解决方案是让编译器在创建的JS文件的开头添加以下内容。
var $_, $hxClasses = $hxClasses || {},
现在,JS文件中的第一行看起来像这个
$estr = function() { return js.Boot.__string_rec(this,''); }
不确定需要做些什么来解决这个问题,或者在编译后手动添加该行之外的其他可能的解决方案?
发现问题-three.js中有Date.hx和Timer.hx文件(旧版本),删除它们后就可以工作了(在我成功安装时,它位于c:''Motion Twin''haxe''lib''three,js''0,2,46''和c:''Motion Twin''haxe''lib ''three、js''0,2.46''haxe)
相关文章:
- 为什么“;未定义的“;在JavaScript中结束循环
- 要求未定义JS回调参数
- 如何检查管道中未定义的项目
- 当项目投入使用时,Javascript是未定义的
- 在 JavaScript 对象中添加子对象时获取“无法设置未定义的属性'项目'”
- AngularJs $scope在离子项目中是未定义的
- 使用 EJS 部分和角度的节点/快速项目:未捕获的引用错误:未定义角度
- AngularJS对于$scope中的项目$scope未定义的
- 在Visual Studio 2015中加载MVC 5项目时,未定义$
- device.platform return'设备未定义'关于cordova项目
- 未捕获的ReferenceError:Haxe-js项目中未定义$hxClasses
- 不能读取property 'top'未定义的Ruby on Rails项目
- 在React项目中,“this”"转换为“未定义”
- jqgrid中的自动完成文本框显示错误,项目未定义
- 如何调用项目中未定义的函数
- 使用Grunt的Node JS项目,生成的JS文件有ReferenceError:窗口未定义
- JSBIN项目:RX.Js 5.0.0拉出'未定义'错误
- Cordova&SQLite-所有行项目返回为'未定义'
- 为d3项目加载csv文件时未定义的值
- cordova.file在android的ionic项目中未定义