开发者

How to bind to same class instance var JavaFX

I'm new to JavaFX, trying to use bind like this:

public function newCircle() : Circle 开发者_运维技巧{
    Circle {        
        centerX: 1
        radius: bind (centerX / prm._iMaxPop)
    }
};

I get "Non-static variable centerX cannot be referenced from a static context." Also tried using this.centerX with same result.

Thanks in advance.


Try using this:

function newCircle() : Circle {
   var xVal =1; 
    Circle {        
            centerX: xVal;
            radius: bind (xVal / prm._iMaxPop)
       }
    }


Can add a temporary variable "c" which must be explicitly typed:

public function newCircle() : Circle {
    var c : Circle = Circle {        
        centerX: 1
        radius: bind (c.centerX / prm._iMaxPop)
    }
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜