PDA

View Full Version : Simple scoring question


caffrey75
11-14-2003, 10:00 AM
Think this is a bit of a simple one, so I've posted it in the Simple Stuff section.

Building a dart game and having problems with the scoring field.

When a dart gets thrown into the board, the score associated with the panel it hits gets passed to variable field on the _root called

'dartscore'

However there is also a field called 'roundscore' which displays the points accumulated by each dart and increments itself after every dart is thrown. I thought this would be so simple and my code looked something like this.

[AS] _root.roundscore += _root.dartscore[AS/]

Unfortunately, all that happens is that a long string of numbers appear in 'roundscore' - no Maths is done at all.

I know if I put something like

[AS] _root.roundscore += 4[AS/]

it works! What's the problem here. Have trawled the boards, but can't find anything......

binkyboo
11-14-2003, 10:42 AM
Is dartscore a string?

Do you have something like dartscore = "20";?

Try this:

_root.roundscore += Number(_root.dartscore)

If the code above worked then the variable 'dartscore' is a string and not a number.

caffrey75
11-14-2003, 10:45 AM
Thanks so much! That worked a right treat....

Much appreciated, binkyboo :)