本人在用命令行编译javafx的时候发现public -init、public -read这些语法无法编译。调了很久都没办法解决。我查了N遍都觉得语法没错。因此发上来给各位大虾、高手看看,万望指点。分不够都可以再加(本人身家范围之内)
代码如下:
package music.piano;import javafx.scene.CustomNode;
import music.piano.player.PianoPlayer;public abstract class PianoKey extends CustomNode{
public -init var xOffset : Number;
public  var yOffset : Number;
public  var note : Integer;
public  var keyText : String;
public  var player : PianoPlayer;
protected var showKeyPress = false;

public function noteOn(): String {
showPress();
player.playOn(note);
return keyText;
}

public function noteOff(): Void {
player.stop(note);
clearPress();
}

public function showPress(): Void {
showKeyPress = true;
}

public function clearPress(): Void {
showKeyPress = false;
}
}
错误信息如下:
PianoKey.fx:7:Sorry, I was trying to understand a 'class' declaration member but I got confused when I saw '-'.
public -init var xOffset : Number;