我不认为我的语法在这里实际上很糟糕。或者是吗?这是我第一次尝试 OpenFL。
Haxe 没有正确编译?我是否缺少编译器指令?我在这个函数中实际上有语法错误吗?Flashdevelop 中的语法检查器说不。
这是命令:
Running process: C:\Program Files (x86)\FlashDevelop\Tools\fdbuild\fdbuild.exe "C:\dev\Haxe\TestOpenFL\OpenFLTest.hxproj" -ipc 2e4ace78-45b9-4868-a2dd-cf2c35265f44 -version "3.0.0" -compiler "C:\HaxeToolkit\haxe" -library "C:\Program Files (x86)\FlashDevelop\Library" -target "flash"
src/Main.hx:32:字符 16-17:意外;构建因错误而停止 (haxelib.exe)。
function init()
{
if (inited) return;
inited = true;
// \/ says this semicolon is unexpected. wtf
for (var i = 0; i < 200; i ++)
{
var bmd = new BitmapData( 100, 100, true, 0xff0000ff);
var bmp = new Bitmap( bmd);
addChild(bmp);
bitmaps.push( bmp );
}
addEventListener( Event.ENTER_FRAME, onEnterFrame );
}
这是整个脚本。我一生都无法弄清楚为什么它会在那里出错。如果我只注释掉循环,它编译得很好。
class Main extends Sprite
{
var inited:Bool;
var bitmaps:Array<Bitmap>;
/* ENTRY POINT */
function resize(e)
{
if (!inited) init();
// else (resize or orientation change)
}
function init()
{
bitmaps = new Array();
if (inited) return;
inited = true;
for (var i = 0; i < 200 ; i ++)
{
// Assets:
var bmd = new BitmapData( 100, 100, true, 0xff0000ff);
var bmp = new Bitmap( bmd);
addChild(bmp);
bitmaps.push( bmp );
}
addEventListener( Event.ENTER_FRAME, onEnterFrame );
}
private function onEnterFrame(e:Event):Void
{
}
/* SETUP */
public function new()
{
super();
addEventListener(Event.ADDED_TO_STAGE, added);
}
function added(e)
{
removeEventListener(Event.ADDED_TO_STAGE, added);
stage.addEventListener(Event.RESIZE, resize);
#if ios
haxe.Timer.delay(init, 100); // iOS 6
#else
init();
#end
}
public static function main()
{
// static entry point
Lib.current.stage.align = flash.display.StageAlign.TOP_LEFT;
Lib.current.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
Lib.current.addChild(new Main());
}
}