1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Actionscript 2.0 - Making A Scoring System

Discussion in 'Software Development' started by KugarWeb, Apr 16, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. KugarWeb

    KugarWeb Thread Starter

    Joined:
    Apr 6, 2007
    Messages:
    143
    Hi there,

    I'm currently working on a number adding game within Flash and have come across a problem with making a total score, as I have had very limited experience with Actionscript (I started learning bits of it last weekend!).

    The basic setup of my game is the following:

    Question 1 >> Question 2 >> Question 3 >> Question 4 >> Question 5 >> Total Score.

    For each question I have two answer boxes, both of which have to be answered correctly for the "order" (related to the game) or question to count. Now I don't want both boxes to be counted, only a score of +1 or 0 for a respective right or wrong answer for each question and then a "Total Score" to be displayed on another frame near the end.

    Whether it's right or not I don't know but below is my code so far. I know the right or wrong if statement works perfectly but I'm really not sure on the "score" or how to even attach this somehow to the rest of the game. Please bear in mind that I have an animation for each question so there's bound to be a few second in between each of the questions - is that a problem for actionscript? Also, since there are a lot of layers all to do with each question, I have had to put them in their own folders (e.g. question1, question2 etc.) which I'm guessing shouldn't also be a problem? :confused:

    Code:
    score = 0;
    order1Right._visible = false;
    order1Wrong._visible = false;
    nextQ2._visible = false;
    alphaQuestion1._visible = false;
    checkOrder1.onRelease = function() {
    	if (input_banana1.text == 3 || input_banana1.text == "three" || input_banana1.text == "Three" || input_banana1.text == "THREE" && input_orange1.text == 2 || input_orange1.text == "two" || input_orange1.text == "Two" || input_orange1.text == "TWO"){
    		input_banana1._visible = false;
    		input_orange1._visible = false;
    		alphaQuestion1._visible = true;
    		order1Right._visible = true;
    		checkOrder1._visible = false;
    		nextQ2._visible = true;
    		score = score +1
    	} else {
    		input_banana1.visible = false;
    		input_orange1._visible = false;
    		alphaQuestion1._visible = true;
    		order1Wrong._visible = true;
    		checkOrder1._visible = false;
    		nextQ2._visible = true;
    	}
    };
    stop();
    Any help with this would be much appreciated! :)
     
  2. TheRobatron

    TheRobatron

    Joined:
    Oct 25, 2007
    Messages:
    551
    To be able to access the score from other frames and movieclips you can declare a global variable: _global.score = 0;

    Also I think it might help with the validation if you put each side of the if statement in brackets:
    Code:
    if ((input_banana1.text == 3 || input_banana1.text == "three" || input_banana1.text == "Three" || input_banana1.text == "THREE") && 
    (input_orange1.text == 2 || input_orange1.text == "two" || input_orange1.text == "Two" || input_orange1.text == "TWO"))
    
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/704298