Eclipse JavaScript使用Node.js导入JavaFX运行时错误

时间:2018-07-14 11:32:45

标签: javascript eclipse javafx import

使用Eclipse PHOTON IDE和Node.js学习Javascript。创建了JavaScript项目并粘贴到示例代码中(请参见下文)。

/**
 * http://usejsdoc.org/
 */
import javafx.stage.*;
import javafx.scene.*;
import javafx.animation.*;
import javafx.scene.effect.*;
import javafx.scene.shape.*;
import javafx.scene.input.*;
import javafx.scene.paint.*;

var balls = for(i in [0..<6]) {
    var c = Circle {
        translateX: (i*40)+90;  translateY: 30;
        radius: 18;
        fill: RadialGradient {
            focusX: 0.25;  focusY:0.25;
            proportional: true;
            stops: [
                Stop { offset: 0; color: Color.WHITE; } ,
                Stop { offset: 1; color: Color.BLACK; }
            ]
        };
    }
}

Stage {
    scene: Scene {
        content: Group {
            content: [
                Rectangle {
                    width: 380;  height: 250;  
                    opacity: 0.01;
                    onMouseClicked: 
                        function(ev:MouseEvent) { FX.exit(); }
                } , balls
            ]
            effect: Reflection {
                fraction: 0.25;  topOffset: -18;
                topOpacity: 0.5;  bottomOpacity: 0.125;
            }
        }
        fill: LinearGradient {
            endX: 0;  endY: 1;  proportional: true;
            stops: [
                Stop { offset: 0.74;  color: Color.TRANSPARENT; } ,
                Stop { offset: 0.75;  color: Color.BLACK } ,
                Stop { offset: 1;  color: Color.GRAY }
            ]
        }
    };
    style: StageStyle.TRANSPARENT
};

Timeline {
    keyFrames: for(i in [0..<sizeof balls]) {
        KeyFrame {
            time: i*200ms;
            action: function() {
                Timeline {
                    repeatCount: Timeline.INDEFINITE;
                    autoReverse: true;
                    keyFrames: [
                        at (0s) { balls[i].translateY => 30 } ,
                        at (1s) { balls[i].translateY => 230 
                            tween Interpolator.EASEIN }
                    ]
                }.play();
            }
        }
    }
}.play();

我收到以下错误:

C:\Users\andyh\workspace\BouncingBalls\src\BouncingBalls.js:4
import javafx.stage.*;
       ^^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:236:19)

此错误看起来像CLASSPATH错误,但我不知道如何解决它。我试图使项目性质成为Java项目,并向库中添加了JavaFX,但这似乎并没有解决它。有任何想法吗。没有JavaFX的简单测试程序可以正常工作。

0 个答案:

没有答案