Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-14-2003, 10:00 AM   #1
caffrey75
Senior Member
 
Join Date: Apr 2001
Location: UK
Posts: 132
Default Simple scoring question

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......
caffrey75 is offline   Reply With Quote
Old 11-14-2003, 10:42 AM   #2
binkyboo
Senior Member
 
binkyboo's Avatar
 
Join Date: Mar 2002
Location: Madison, Wisconsin
Posts: 1,312
Send a message via MSN to binkyboo
Default

Is dartscore a string?

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

Try this:

ActionScript Code:
_root.roundscore += Number(_root.dartscore)

If the code above worked then the variable 'dartscore' is a string and not a number.
binkyboo is offline   Reply With Quote
Old 11-14-2003, 10:45 AM   #3
caffrey75
Senior Member
 
Join Date: Apr 2001
Location: UK
Posts: 132
Default Perfect

Thanks so much! That worked a right treat....

Much appreciated, binkyboo
caffrey75 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My brain hurts (onClipEvent question) andrea_levin ActionScript 2.0 3 03-25-2004 04:23 AM


All times are GMT. The time now is 09:51 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.