Learning Javascript using Eclipse PHOTON IDE and Node.js. Created JavaScript project and pasted in the example code (see below).
/**
* 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();
I get the following error:
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)
This error looks like a CLASSPATH error, but I cant figure out how to resolve it. I tried making the project nature a Java project and added JavaFX to the libraries, but that doesn't seem tp have resolved it. Any ideas. Simple test programs without JavaFX work fine.