the following code is for an on-line exam. When a selection is made the selection is highlighted and then de-selected when you click off the answer. I need to allow for multiple selections, that is when you click on one answer and then another, both will be hi-lighted. Was hoping someone could look at this code and help me determine how to do that.
package exam {
import flash.display.*;
import flash.events.*;
import flash.text.*;
//This class displays the current question, and contains the Choices for the question
public class QMachine extends Sprite {
//VARIABLES
private var QObject:Object; //object from XaMLDiplomat, containing necessary text
private var limit:Number;
private var QNumTxt:TextField;
private var QTxt:TextField;
private var txtStyle:StyleSheet;
private var choiceA:Choice;
private var choiceB:Choice;
private var choiceC:Choice;
private var choiceD:Choice;
private var choiceE:Choice;
private var choiceF:Choice;
//CONSTRUCTOR
public function QMachine (hite:Number) {
limit = hite;
var style:Object = new Object();
style.fontFamily = "Arial";
//style.fontWeight = "bold";
style.fontSize = "16";
style.color = "#333333";
txtStyle = new StyleSheet();
txtStyle.setStyle("p",style);
QNumTxt = new TextField();
QNumTxt.styleSheet = txtStyle;
//QNumTxt.embedFonts = true;
QNumTxt.htmlText = "<p>1) </p>";
QNumTxt.autoSize = TextFieldAutoSize.RIGHT;
QNumTxt.x = 10;
QNumTxt.mouseEnabled = false;
QTxt = new TextField();
QTxt.styleSheet = txtStyle;
//QTxt.embedFonts = true;
QTxt.width = 300;
QTxt.multiline = true;
QTxt.wordWrap = true;
QTxt.autoSize = TextFieldAutoSize.LEFT;
QTxt.htmlText = "<p>Question 1</p>";
QTxt.x = 35;
QTxt.mouseEnabled = false;
addChild(QNumTxt);
addChild(QTxt);
choiceA = new Choice("a");
choiceA.x = 350;
addChild(choiceA);
choiceB = new Choice("b");
choiceB.x = 350;
addChild(choiceB);
choiceC = new Choice("c");
choiceC.x = 350;
addChild(choiceC);
choiceD = new Choice("d");
choiceD.x = 350;
addChild(choiceD);
choiceE = new Choice("e");
choiceE.x = 350;
addChild(choiceE);
choiceF = new Choice("f");
choiceF.x = 350;
addChild(choiceF);
addEventListener(MouseEvent.MOUSE_UP, selectResponse, true);
}
internal function newQuestion (obj:Object, prior:String = ""):void {
//trace(obj.num);
QNumTxt.htmlText = "<p>"+ obj.num + ".</p>";
QTxt.htmlText = "<p>"+ obj.q + "</p>";
choiceA.deselect();
choiceB.deselect();
choiceC.deselect();
choiceD.deselect();
choiceE.deselect();
choiceF.deselect();
choiceA.resetSize();
choiceB.resetSize();
choiceC.resetSize();
choiceD.resetSize();
choiceE.resetSize();
choiceF.resetSize();
choiceA.changeTxt(obj.ca);
choiceB.changeTxt(obj.cb);
choiceB.y = choiceA.height + 5;
if (obj.cc == undefined || String(obj.cc) == "") {
choiceC.visible = false;
}else {
choiceC.changeTxt(obj.cc);
choiceC.y = choiceB.y + choiceB.height + 5;
choiceC.visible = true;
}
if (obj.cd == undefined || String(obj.cd) == "") {
choiceD.visible = false;
}else {
choiceD.changeTxt(obj.cd);
choiceD.y = choiceC.y + choiceC.height + 5;
choiceD.visible = true;
}
if (obj.ce == undefined || String(obj.ce) == "") {
choiceE.visible = false;
}else {
choiceE.changeTxt(obj.ce);
choiceE.y = choiceD.y + choiceD.height + 5;
choiceE.visible = true;
}
if (obj.cf == undefined || String(obj.cf) == "") {
choiceF.visible = false;
}else {
choiceF.changeTxt(obj.cf);
choiceF.y = choiceE.y + choiceE.height + 5;
choiceF.visible = true;
}
var curHite:Number;
if (choiceF.visible) {
curHite = choiceF.y + choiceF.height + 5;
}else if (choiceE.visible) {
curHite = choiceE.y + choiceE.height + 5;
}else if (choiceD.visible) {
curHite = choiceD.y + choiceD.height + 5;
}else {
curHite = choiceC.y + choiceC.height + 5;
}
if (curHite > (limit-150)) {
shrinkText();
}
if (prior != "") {
if (prior == "a") {
choiceA.nowSelected();
}else if (prior == "b") {
choiceB.nowSelected();
}else if (prior == "c") {
choiceC.nowSelected();
}else if (prior == "d") {
choiceD.nowSelected();
}else if (prior == "e") {
choiceE.nowSelected();
}else if (prior == "f") {
choiceF.nowSelected();
}
}
}
private function shrinkText() {
choiceA.dropSize();
choiceB.dropSize();
choiceC.dropSize();
choiceD.dropSize();
choiceE.dropSize();
choiceF.dropSize();
choiceB.y = choiceA.y + choiceA.height + 5;
choiceC.y = choiceB.y + choiceB.height + 5;
choiceD.y = choiceC.y + choiceC.height + 5;
choiceE.y = choiceD.y + choiceD.height + 5;
choiceF.y = choiceE.y + choiceE.height + 5;
var curHite:Number = 0;
if (choiceF.visible) {
curHite = choiceF.y + choiceF.height + 5;
}else if (choiceE.visible) {
curHite = choiceE.y + choiceE.height + 5;
}else if (choiceD.visible) {
curHite = choiceD.y + choiceD.height + 5;
}else {
curHite = choiceC.y + choiceC.height + 5;
}
if (curHite > (limit-150)) {
shrinkText();
}
}
private function selectResponse (e:MouseEvent):void {
choiceA.deselect();
choiceB.deselect();
choiceC.deselect();
choiceD.deselect();
choiceE.deselect();
choiceF.deselect();
var letter:String = e.target.parent.getLetter();
dispatchEvent(new ResponseEvent(ResponseEvent.SELECTION, letter));
}
internal function setPriorResponse() {
choiceA.deselect();
choiceB.deselect();
choiceC.deselect();
choiceD.deselect();
choiceE.deselect();
choiceF.deselect();
}
}
}