Skip to main content

strange cast with bind operator

1 reply [Last post]
Joined: 2006-11-10

HI to all,

during my tests i get some problem with bind operator and casting.
This snippets doesn't works if in Stage.content there is "bind" operator.

var steps:Number = 100;
Frame {
title: "MyApplication"
width: 200
height: 200
closeAction: function() {
java.lang.System.exit( 0 );
visible: true

stage: Stage {
content: bind [
// why i need cast steps to Integer?
for(i in [0..steps as Integer ]) {
Text {
font: Font {
size: 8
style: FontStyle.PLAIN

// workaround text position as default have baseline
textOrigin: TextOrigin.TOP;
// if I use bind operator i get an exception:
content: "i" + i ;



The exception throws is :
.../.../TestConcatenate.fx:43: cannot find symbol
symbol : method plus_oi(com.sun.javafx.runtime.location.ObjectLocation,com.sun.javafx.runtime.location.IntLocation)
location: class com.sun.javafx.runtime.location.BoundOperators

I feel strange that variable steps must be cast as Integer when it is on for operator.
Anyway it seams that binding and casting have some relation.
Any idea or explanation about this behavior?

thanks in advance
regards Lorenzo

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-07-12

The steps should have Integer type instead of Number.
Just declare it:

var steps = 100; // So steps has Integer type.

To convert expression to string use [b]"{expr}"[/b]:

content: "{i+1}"