AS 2.0 Based Quiz

I have all the actionscript written, and the first frame of my FLA loading a dummy set of questions and options for each question.

For some bizarre reason, it doesn’t seem to understand that the movieClip I’ve created should correlate to my Option class.

The linking option is set to export the movie clip i created for each option as actionscript as an ‘Option’ object.

Each object drawn is getting the properties of my Option, but the properties don’t seem to be holding.

Any help would be greatly appreciated!

Quiz.as


/**
* Handles Quiz Operations
*/
class Quiz
{
    // Variables
    private var title:String='';
    private var questions:Array= new Array;
    private var _curQuestionNum=0;

    /**
    * Constructor
    * @param String title
    */
    public function Quiz( title:String )
    {
        this.SetTitle( title );
    }
    
    /** 
    * Gets the title of this quiz
    * @return String
    */
    public function GetTitle():String
    {
        return this.title;
    }
    
    /** 
    * Sets this quiz's title
    * @param String title
    */
    public function SetTitle( title:String )
    {
        this.title = title;
    }
    
    /**
    * Returns the current question viewed by the user
    * @return Question
    */
    public function GetCurQuestion():Question
    {
        return this.questions[this._curQuestionNum];
    }
    
    /**
    * Returns the next question in this quiz
    * @return Question
    */
    public function GetNextQuestion():Question
    {
        if( this._curQuestionNum == (this.questions.length-1) ) return null;
        return this.questions[this._curQuestionNum++];
    }
    
    /**
    * Returns a string which indicates which question we are on out of the total
    * @return String
    */
    public function GetCurQuestionText():String
    {
        return 'Question '+ ( this._curQuestionNum + 1 ) + ' of ' + this.questions.length;
    }
    
    /**
    * Returns the total number of questions in the quiz
    * @return int
    */
    public function GetNumQuestions()
    {
        return this.questions.length;
    }
    
    /**
    * Calculates how many questions were correctly answered in this quiz
    * @return int
    */
    public function GetNumCorrectAnswers()
    {
        var correct = 0;
        // Loop through our questions
        for(var i = 0; i<this.GetNumQuestions(); i++)
        {
            // if the question was answered correctly, tally it
            if( this.questions*.AnsweredCorrectly() ) correct++;
        }
        // return the number of correct answers
        return correct;
    }
    
    /** 
    * Calculates how many questions were incorrectly answered in this quiz
    * @return int
    */
    public function GetNumWrongAnswers()
    {
        var wrong = 0;
        // Loop through our questions
        for(var i = 0; i<this.GetNumQuestions(); i++)
        {
            // if the question was answered incorrectly, tally it
            if( !this.questions*.AnsweredCorrectly() ) wrong++;
        }
        // return the number of incorrect answers
        return wrong;
    }

    /**
    * Adds a Question to this quiz
    * @param Question q
    */
    public function AddQuestion( q:Question )
    {
        this.questions.push(q);
    }

    /**
    * Calculates how well the user did in answering the questions of this quiz
    * @return int
    */
    public function GetCorrectAnswerPercentage()
    {
        return Math.floor( (this.GetNumCorrectAnswers() / this.GetNumQuestions()) * 100 );
    }
    
    /**
    * Calculates a percentage of how many of the user's answers were incorrect throughout the quiz
    * @return int
    */
    public function GetWrongAnswerPercentage()
    {
        return Math.floor( (this.GetNumWrongAnswers() / this.GetNumQuestions()) * 100 );
    }
    
    /**
    * String representation of this quiz
    * @return String
    */
    public function toString():String
    {
        var returnStr = this.title + "
";
        for(var i=0;i<this.questions.length;i++)
            returnStr += this.questions*.toString();
        return returnStr;
    }
}

Option.as


/**
* handles question options
*/
class Option
{
    // variables
    private var title:String;
    private var answer:Boolean;
    
    /**
    * Option contructor
    * @param String title
    * @param bool isAnswer
    */
    public function Option( title:String, isAnswer:Boolean )
    {
        this.SetTitle( title );
        this.answer=isAnswer;
    }
    
    /**
    * Sets the title of this option
    * @param String title
    */
    public function SetTitle( title:String )
    {
        this.title=title;
    }
    
    /**
    * Indicates whether or not this option is an answer
    * @return bool
    */
    public function isAnswer():Boolean
    {
        return (this.answer==true);
    }
    
    /**
    * Returns the title of this option
    * @return String
    */
    public function GetTitle():String
    {
        return this.title;
    }
    
    /**
    * Returns a string representation of this option
    * @return String
    */
    public function toString():String
    {
        return (this.isAnswer() ? '[+] ' : '') + this.GetTitle() + "
";
    }
}

Question.as


/**
* Quiz Items
*/
class Question
{
    // Variables
    private var category:String;
    private var title:String;
    private var options:Array = new Array;
    // which option the user chose for this question
    private var optionChosen = null;
    
    /**
    * Question Constructor
    * @param String title
    * @param String category
    */
    public function Question( title:String, category:String )
    {
        this.SetCategory(category);
        this.SetTitle(title);
    }
    
    /** 
    * Sets this question's title
    * @param String title
    */
    public function SetTitle( title:String )
    {
        this.title=title;
    }
    
    /**
    * Returns this questions's title
    * @return String
    */
    public function GetTitle():String
    {
        return this.title;
    }
    
    /**
    * Adds an option to this question
    * @param Option o
    */
    public function AddOption( o:Option )
    {
        this.options.push(o);
    }
    
    /**
    * Sets this question's category
    * @param String category
    */
    public function SetCategory( category:String )
    {
        this.category=category;
    }
    
    /**
    * Indicates if this question was answered correctly or incorrectly
    * @return bool
    */
    public function AnsweredCorrectly():Boolean
    {
        return (this.isAnswered() && this.optionChosen.isAnswer());
    }
    
    /**
    * Returns the options for this question
    * @return Array
    */
    public function GetOptions():Array
    {
        return this.options;
    }
    
    /**
    * Sets the option the user chose to answer this question
    * @param Option option
    */
    public function SetOptionChosen( option:Option )
    {
        trace( option.isAnswer() ? 'Correct Answer' : 'Incorrect Answer' );
        this.optionChosen=option;
    }
    
    /**
    * Indicates if this question has been answered
    * @return bool
    */
    public function isAnswered():Boolean
    {
        return this.optionChosen==null ? false : true;
    }
    
    /**
    * Returns the option selected
    * @return Option
    */
    public function GetSelectedAnswer()
    {
        return this.optionChosen;
    }
    
    /**
    * Returns the option at a particular position
    * @return Option
    */
    public function GetOptionAt(i):Option
    {
        return this.options*;
    }
    
    /**
    * Displays a text version of this question and its options
    * @return String
    */
    public function toString():String
    {
        var returnStr = this.GetTitle() +"
";
        for(var i=0;i<this.options.length;i++)
            returnStr += (this.options*.isAnswer() && this.isAnswered() ? '[+] ' : '') + this.options*.GetTitle() + "
";
        return returnStr;
    }
}

My FLA’s ActionScript


import mx.transitions.Tween;
import mx.transitions.easing.*;
import Quiz;
import Option;
import Question;

/** This is all temporary, the 
    real quiz will be loaded from an XML document
*/
/** Create a quiz **/
var myQuiz = new Quiz('My Quiz');

/** Create a question **/
var question1 = new Question('When was the war of 1812 fought?','installation');
/** Set some options **/
var question1Options = new Array(
                        new Option('1791',false),
                        new Option('3 BC',false),
                        new Option('1812',true)
                    );
/** Apply the options to our question **/
for(i=0;i<question1Options.length;i++)
    question1.AddOption(question1Options*);

/** Create a question **/
var question2 = new Question('Who is the current president of the US?','installation');
/** Set some options **/
var question2Options = new Array(
                        new Option('George W Bush',true),
                        new Option('Bill Clinton',false),
                        new Option('Captain Planet',false)
                    );
/** Apply the options to our question **/
for(i=0;i<question2Options;i++)
    question2.AddOption(question2Options*);

/** Add our questions to the quiz **/
myQuiz.AddQuestion(question1);
myQuiz.AddQuestion(question2);

/** Set-Up the Quiz **/
titlebar.quiz_title.text = myQuiz.GetTitle();
var curQuestion = myQuiz.GetCurQuestion();
question_title.text = curQuestion.GetTitle();
step.curQuestionText.text = myQuiz.GetCurQuestionText();
var curOptions = curQuestion.GetOptions();

/** For each option in this question ... **/
for(i=0;i<curOptions.length;i++)
{
    /** Determine the next layer available to draw on **/
    var depth = _root.getNextHighestDepth();
    
    /** Draw our movieClip on the stage, with a 5 pixel bottom margin **/
    this.attachMovie("Option", 'option'+i, depth, {_x:80, _y:100+(55*i)});
    
    /** Set a variable we can use to access this clip **/
    var newClip = _root.getInstanceAtDepth(depth);
    
    /** Set the option's Number **/
    newClip.option_id.text = i+1;
    
    /** Set the option's Title **/
    newClip.option_title.text = curOptions*.GetTitle();

    /** Fade the option into place **/
    var slide = new Tween(newClip, "_alpha", Regular.easeOut, 0, 100, 0, true);
    slide.continueTo(100, 1);

    /** Trigger an event when our button is clicked **/
    newClip.onPress = function()
    {
        curQuestion.SetOptionChosen( curQuestion.GetOptionAt(i) );
        trace( curQuestion.toString() );
        trace( curQuestion.GetSelectedAnswer() );
    }
}