Game Scoring Problem

[COLOR=black][FONT=Arial]Hi[/FONT][/COLOR]

[COLOR=black][FONT=Arial]Im having troubles developing what I thought would be a simple score formula.[/FONT][/COLOR]

[COLOR=black][FONT=Arial]I found some old game scoring source, but unfortunately it only works with Flash 6. Im currently using Flash 8.[/FONT][/COLOR]

[COLOR=black][FONT=Arial]Looking at the attached .fla I hope you can work out what it is i was trying to achieve. my AS is entirely wrong and is only there to give anyone willing to help an idea of what I wanted it to do. Otherwise, this it also the code:[/FONT][/COLOR]

[COLOR=black][FONT=Arial]

stop();
p1_mc.onRelease = function() {
 _root.p1Score = _root.p1Score + 10;
};
p2_mc.onRelease = function() {
 _root.p2Score = _root.p2Score + 10;
};
end_mc.onRelease = function() {
 if (p1Score > p2Score) {
  gotoAndStop("p1win");
 else (p1Score < p2Score) {
  gotoAndStop("p2win");
 else (p1Score == p2Score) {
  gotoAndStop("draw");
};

[/FONT][/COLOR]

[COLOR=black][FONT=Arial]The counting formula works fine with Flash 6, but the final function to determine who is the winner, loser or if its a draw is completely wrong.[/FONT][/COLOR]

[COLOR=black][FONT=Arial]Can anybody possibly help me please? it’s driving me mad.[/FONT][/COLOR]

[COLOR=black][FONT=Arial]Thanx[/FONT][/COLOR]


Threesome mwm

You need to initialize those variables now- whereas in flash 6 or below (I think), variables were automatically set to 0. So:

_root.p1Score = 0;
_root.p2Score = 0;
stop();

// rest of the code here

That works fine, however the main issue now is the “end_mc” button.

I need it to calculate the winner, loser, or a draw.

end_mc.onRelease = function() {
	if (p1Score > p2Score) {
		gotoAndStop("p1win");
	else (p1Score < p2Score) {
		gotoAndStop("p2win");
	else (p1Score == p2Score) {
		gotoAndStop("draw");
};

Thanx for the speedy reply.


METH REHAB ADVICE

I still havent managed to find a solution. Can anybody help please?


TUBE ****

a few things wrong with your code, and your win labels were missing the s.

_root.p1Score = 0;
_root.p2Score = 0;
stop();
p1_mc.onRelease = function() {
_root.p1Score = _root.p1Score+10;
};
p2_mc.onRelease = function() {
_root.p2Score = _root.p2Score+10;
};
end_mc.onRelease = function() {

if (_root.p1Score&gt;_root.p2Score) {
    gotoAndStop("p1wins");
} else if (_root.p1Score&lt;_root.p2Score) {
    gotoAndStop("p2wins");
} else if (_root.p1Score == _root.p2Score) {
    gotoAndStop("draw");
}

};

horray! Thank you, I was so close too. :slight_smile:


OREGON DISPENSARY