Flash - Millionaire

A concept on how a millionaire game would look in code.

Getting Started

Flash uses ActionScript and it's very messy. I completed this project in college while using the criteria the instructor requested.

On the main menu, it displays the logo and two buttons; play game and how to play. The simple code below is for redirecting the user to a different scene.

import flash.events.MouseEvent;

stop();

playTheGameButton.addEventListener(MouseEvent.CLICK,playTheGame);
HelpButton.addEventListener(MouseEvent.CLICK,HowToPlay);

function playTheGame(event:MouseEvent){
    gotoAndPlay("UserInputName");
}

function HowToPlay(event:MouseEvent){
    gotoAndPlay("HowToPlay");
}

The HowToPlay scene just displays text on how to play and contains a button to go back to the main menu scene.

UserInputName Scene

A simple textbox and submit button appears. It asks the player to fill out their full name and to continue. The player name will be printed on a fake cheque of the winnings earned when the game is over.

stop();
startButton.addEventListener(MouseEvent.CLICK,startTheGame);
usernameInput.text = username;
currentBankedText = "Zero Dollars";

function startTheGame(event:MouseEvent){
    username = usernameInput.text;
    gotoAndPlay("Amounts");
}

To make things user friendly, I used String instead of Integer to display current bank amounts.

Questions Scene

In Millionare, there are questions and answers but not all answers are correct. I needed to come up with a solution on how to seperate this -- the easiest way was arrays. I could randomize the questions using arrays so that the game would not be boring and repetative.

var question:Array; //a string array that holds only questions
var answer:Array;   //a string array that holds the actual answer

//string arrays that holds the possible answer - one will always be correct determined by the array `answer`
var answerA:Array;
var answerB:Array;
var answerC:Array;
var answerD:Array;

An idea on what questions and answers would look like:

if(currentQuestion == 1){
    //Question 1 - $100 Dollars
    question = new Array(
    "What does JCL stand for?", 
    "What does COBOL stand for?", 
    "What does VB stand for?",
    "What does SQL stand for?",
    "What does HTML stand for?"
    );
    answer = new Array(
    'B','C','A','A','B'
    );
    answerA = new Array(
    "Job Cobol Language", 
    "Common Business Object Language", 
    "Visual Basic",
    "Structured Query Language",
    "Hyper Markup Language"
    );
    answerB = new Array(
    "Job Control Language",
    "CPU Business Oriented Language",
    "Virtual Basic",
    "Structured Question Language",
    "Hypertext Markup Language"
    );
    answerC = new Array(
    "Job Creating Language",
    "Common Business Oriented Language",
    "Virtual Business",
    "Super Quiz Language",
    "Hypertext Language"
    );
    answerD = new Array(
    "Just Crackling Lava",
    "Crappy Objects Language",
    "Visual Bam!",
    "Some Question Language",
    "Hilarious Type Mock Language"
    );
}

The code is lengthy above but it was super simple to randomize a number to select a random question with it's corresponding answers.

//display question and answers on stage
index = Math.floor(Math.random() * question.length);
questionText.appendText(question[index]);
answerOneText.appendText(answerA[index]);
answerTwoText.appendText(answerB[index]);
answerThreeText.appendText(answerC[index]);
answerFourText.appendText(answerD[index]);

Knowing what I know now, I would have not done it this way. I would have setup a multi-dimensional array that shuffles each question and answer accordingly.

//concept                                                        correct answer below
//question, answer, answerA, answerB, answerC, answerD
question("What does JCL stand for?", "B", "Job Cobol Language", "Job Control Language", "Job Creating Language", "Just Crackling Lava",...);

Game Over

There is more coding in this project overall like the GUI interface but I'm not willing to give the entirety of the code away. The code below will display the userinput and winnings on a fake cheque on the screen to the player.

stop();

usernameOnCheque.appendText(username);
numbersOnCheque.appendText(currentBanked);
amountOnCheque.appendText(currentBankedText);

playAgainButton.addEventListener(MouseEvent.CLICK,playAgain);

Image of Scoreboard

Millionaire

Everytime the player gets an answer right, this scene displays on the player's screen. The orange bar (shown at the 15th question; one million dollar question) will start at the $100 question and increment by the height of the box every time the player gets the question right. It's just a simple way of showing the current question and winnings. That means the spacing has to be perfect so the box isn't overlapping or going off course.