3 Replies Latest reply on Jan 10, 2011 3:23 PM by kglad

Developing a simple score counter

Working on a simple score counter for my young son -- the idea is to simply add or subtract 1 digit to reveal the score. The variables only need to be 0-9 in each column. Can someone advise on how to make this work correctly?

The animation was developed using a root.xxxx +1 or -1. It does the trick but as you can see, it keeps going into the double digits in each column.

Any help is much appreciated and my 7 YO will be thrilled. He personally does not care about the code glitch -- but his perfectionist Dad does

Thanks for any help that can be given.

Jeff

• 1. Re: Developing a simple score counter

check each column's counter to see when it exceeds 9 or is less than 0.   when either of those occur update the current column and the column to the left or right as needed.

• 2. Re: Developing a simple score counter

Thanks so much for the quick reply. Unfortunately, my knowledge of AS is very limited. I found a sample code and tailored it for this use, but unable to modify it according to your suggestions. Where do I add the variable for these buttons?

For each [ + ] button:

on (release) {
_root.thou = _root.thou + 1;
}

with "thou", being "hun", "ten", and "one" respective to each column.

For each { - } button:

on (release) {
_root.thou = _root.thou i 1;
}

with "thou", being "hun", "ten", and "one" respective to each column.

in a separate frame on the timeline:

thou = 8; hun = 0; ten = 0; one = 0;
thou2 = 8; hun2 = 0; ten2 = 0; one2 = 0

to make the number start at 8000 for each score

How do I keep the numbers to stay in the range from 0-9?

It is easier to just shift the numbers to the right score instead of making this add up as there are different points awarded. Thanks for all of your help.

• 3. Re: Developing a simple score counter

you would use something like:

// thou plus

on (release) {
_root.hundreds = _root.hundreds + 1;

if(_root.hundreds==10){

_root.hundreds=0;

_root.thousands++;

}
}

// thou minus

on (release) {
_root.hundreds = _root.hundreds - 1;

if(_root.hundreds==-1){

_root.hundreds=0;

_root.tens++;

}
}

1 person found this helpful