flash actionscript:
In the past, I could dynamically add variables to a movie clip to assign values
to them so that I was able to read them later per movie clip.
It doesn't seem like I can do this now. Is there anyway to do it?
Also, this is in a class, and when the student has answerd the quesiton, I
need variables to be set from the main stage. (nextEnabled, backEnabled for
buttons to become active). So on a side note, from a class, how do I set
variables in the main stage?
thanks in advance
This is for a XML generated exam, and I'm creating the answers dynamically
here:
for(var i:uint=0; i<ansTot; i++) {
var arNum:uint = Number(listArray[i]);
var disMC:MovieClip = new MovieClip();
var ansText:TextField = new TextField();
disMC.addChild(ansText).name = "ansText";
ansText.x = 15;
if(i == 0) {
thisY = stemText.height + 20;
ansText.y = thisY;
} else {
ansText.y = thisY;
}
ansText.width = 969;
ansText.autoSize = TextFieldAutoSize.LEFT;
ansText.styleSheet = quesCSS;
ansText.wordWrap = true;
ansText.multiline = true;
ansText.selectable = false;
ansText.condenseWhite = true;
ansText.antiAliasType = "advanced";
//ansText.border = true;
ansText.borderColor = 0xFFFFFF;
ansText.htmlText = "<span class='n'>" + formatScreenText(subXML[arNum]) +
"</span>";
disMC.defaultText = formatScreenText(subXML[arNum]);
disMC.remediation = subXML[arNum].@remediation;
disMC.isCorrect = subXML[arNum].@correct;
disMC.addEventListener(MouseEvent.CLICK, answerClicked);
thisY += ansText.height + 10;
this.addChild(disMC);
}
private function answerClicked(event:Event):void {
var myAns = event.target;
if(this.isCorrect == "1") {
this.ansText.htmlText = "<span class='cor'>" + this.defaultText + "</span>";
} else {
this.ansText.htmlText = "<span class='wng'>" + this.defaultText + "</span>";
}
}