tags:

views:

48

answers:

2

I have little quiz game I've working on and am tracking correct answers. I have a text object that displays the number of consecutive correct answers. This is the content:

content: bind consecutive.toString();

What I would like to do is mix that in with some string output like this:

content: "{bind consecutive.toString()} in a row!"

Unfortunately that gives me an error complaining about the bind keyword. Creating some intermediary variable is not much better:

var consec_disp = bind consecutive;
content: "{consec_disp.toString()} in a row!"

Although this compiles it only ever displays "0 in a row!"

Anyone have any ideas?

A: 

Have you tried?

content: bind "{consecutive.toString()} in a row!"

Unless I'm horribly mistaken that should solve your problem.

Eric Wendelin
Ha! I thought of it but for some reason wrote it off thinking it would never work. Obviously I was wrong because it works like a charm.Thanks Eric!
Mike Williamson
No prob :) Anytime you have questions, post 'em here and I'll get to them since I review all the javafx questions.
Eric Wendelin
A: 

Better yet:

content: bind "{consecutive} in a row!"

{} implies that toString() will be called on the variable.

JimClarke