[JavaFX] 请教JavaFX语法的问题

chenweionline 2009-10-18
IDE在以下JavaFX代码的第29行和第36行分别报出错误警告,请教原因?
我使用的IDE是NetBeans IDE 6.7.1,JavaFX SDK版本为1.2。

29 line:This is the cyclic reference to fade that prevents type inference
36 line:Need explicit type for fade because of cycle in definition

package org.jqueen.fx.test;

import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.animation.Timeline;
import javafx.scene.Group;
import javafx.animation.Interpolator;

/**
 * @author Leon Chen
 */

var group0 : Group = Group{
    content: [
        Button {
            text: "Button 0"
            action: function() {
                fade();
            }
        }
    ]
};
var group1 : Group = Group{
    content: [
        Button {
            text: "Button 1"
            action: function() {
                fade();
            }
        }
    ]
};
var group : Group[] = [group0, group1];

function fade(){
    Timeline {
            keyFrames : [
                    at(1000ms){group[0].opacity => 0.0 tween Interpolator.LINEAR}
            ]
    }.play();
}

Stage {
        title : "MyApp"
        scene: Scene {
                width: 200
                height: 200
                content: [
                        group
                        ]
        }
}
MyJavaFX 2009-10-19
报错的原因是循环调用没有指定返回类型。函数fade添加返回类型应该就可以解决,如function fade(): Void
chenweionline 2009-10-21
果然是这样,这个错误是我对JavaFX函数语法的误解造成的。
多谢解答。
Global site tag (gtag.js) - Google Analytics