how to share the same function from different frames
I'm creating a multiple choice quiz with multiple questions.
I have each clickable selection using "answer1", "answer2" ... as instance name.
I created standard button to show different states and make selection (like what's below):
answer1.buttonMode = true;// to show hand icon
answer1.addEventListener(MouseEvent.CLICK, answer1Click);
answer1.addEventListener(MouseEvent.ROLL_OVER, answer1Rollover);
answer1.addEventListener(MouseEvent.ROLL_OUT, answer1Rollout);
function answer1Click(ev:MouseEvent):void
{
answer1.gotoanswerndStop(2);
answer2.gotoanswerndStop(1);
answer3.gotoanswerndStop(1);
answer4.gotoanswerndStop(1);
sel = 1;
}
function answer1Rollover(ev:MouseEvent):void
{
answer1.gotoanswerndStop(2);
}
function answer1Rollout(ev:MouseEvent):void
{
if (sel != 1)
{
answer1.gotoanswerndStop(1);
}
}
I duplicate the frame for different questions but I can't reuse the same functions for the first question. It would give "Duplicate function definition." error. I don't want to rename the instance names for each new question. How can I reuse the same function for all questions?
Thanks,
