使用此功能,显示多项选择题和答案。但是,当用户单击 A、B、C、D、E 的“答案选项”时,我想要像这样http://www.cambridge.org/other_files/Flash_apps/inuse/EVUElementaryTest/EVUElementaryIndex.htm围绕选项的字母画一个圆圈。 这可能吗?
function showQuestions(index,limit ):void{
var mainContainer:Sprite = new Sprite();
mainContainer.name="qContainer";
//mainContainer.graphics.beginFill(0xffffff);
mainContainer.graphics.drawRect(0,0,700, 500);
mainContainer.x=(stage.stageWidth - 700) /2;
mainContainer.y=(stage.stageHeight - 500) /2;
addChild(mainContainer);
for (i=index; i < (index+limit); i++) {
var questionTextField = new TextField();
mainContainer.addChild(questionTextField);
questionTextField.text=i + " " + qnodes[i].QUESTION.text();
questionTextField.name=i;
questionTextField.width=400;
questionTextField.x= 0;
questionTextField.y=i%limit * 100;
var numberOfAnswers= (qnodes[i].OPT.length())
var j:Number;
for (j=0; j < numberOfAnswers; j++) {
var answerTextField = new TextField();
mainContainer.addChild(answerTextField);
var optionLetterMc = new MovieClip();
optionLetterMc.name="Answer"+i;
optionLetterMc.x=((j%3) * 250) ;
optionLetterMc.y= (i%limit * 100) + 20 + (int(j / 3) * 20) ;
optionLetterMc.addEventListener(MouseEvent.CLICK, OnAnswerSelected);
optionLetterMc.addEventListener(MouseEvent.CLICK, saveStudentAnswer);
mainContainer.addChild(optionLetterMc);
var optLetterTextField = new TextField();
optionLetterMc.addChild(optLetterTextField);
optLetterTextField.text=optionLetters[j];
optLetterTextField.name=i;
answerTextField.autoSize = TextFieldAutoSize.LEFT;
answerTextField.x=((j%3) * 250) + 20 ;
answerTextField.y= (i%limit * 100) + 20 + (int(j / 3) * 20) ;
answerTextField.text=qnodes[i].OPT[j].text();
}
}
var btn:Button = new Button();
btn.label = "Next";
btn.x=(stage.stageWidth - 300) /2;
btn.y=500;
mainContainer.addChild(btn);
btn.addEventListener(MouseEvent.CLICK, nextQuestions);
}
更新:我所做的更改:我创建了optionLetterMc,然后在里面添加了 optionTextField。它们被命名为optionLetterMc.name="Answer"+i;
这是你的部分(改变了一点)。
var mSelectedAnswer:MovieClip;
Mouse.hide();
Pencil.mouseEnabled = false;
stage.addEventListener(MouseEvent.MOUSE_MOVE, OnMouseMove);
//Answer1.addEventListener(MouseEvent.CLICK, OnAnswerSelected);
function OnMouseMove(e:MouseEvent):void
{
Pencil.x = stage.mouseX;
Pencil.y = stage.mouseY;
}
function OnAnswerSelected(e:MouseEvent):void
{
mSelectedAnswer = e.currentTarget as MovieClip;
DeselectAll();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, OnMouseMove);
Pencil.addEventListener(Event.ENTER_FRAME, OnAnswerEnterFrame);
Pencil.gotoAndPlay("Draw_Circle");
//trace(mSelectedAnswer.name);
}
function OnAnswerEnterFrame(e:Event):void
{
if(e.target.currentFrame == e.target.totalFrames)
{
trace(mSelectedAnswer.name);
mSelectedAnswer.gotoAndStop("Selected");
Pencil.removeEventListener(Event.ENTER_FRAME, OnAnswerEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_MOVE, OnMouseMove);
}
}
function DeselectAll():void
{
mSelectedAnswer.gotoAndStop("Normal");
}