I have up to 4 buttons on a particular frame which will correspond to answers of a quiz.
They are individually generated by the quiz, and all 4 need to be unloaded when one of them is pressed.
Can someone please give me a hint as to how I can acheive this or point me in the right direction? Thank you!
What happens when a question will be displayed onscreen…
function DisplayQuestion( curQuestion:Question )
{
// Update the display
question_title.text = curQuestion.GetTitle();
// Indicate which question out of our total we are on
step.curQuestionText.text = myQuiz.GetCurQuestionText();
// Retrieve this question's options
var curOptions = curQuestion.GetOptions();
// Loop through our options
for(var i=0;i<curOptions.length;i++)
{
// Determine the next layer available to draw on
var depth = _root.getNextHighestDepth();
curOptions*._x = buttonXStart;
curOptions*._y = buttonYStart+((50+buttonMargin)*i);
// Draw our movieClip on the stage, with a 5 pixel bottom margin
this.attachMovie("Option", 'option'+i, depth, curOptions*);
// 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 slider = new Tween(newClip, "_y", Regular.easeOut, 700, 140, 1, true);
slider.continueTo(buttonYStart+((50+buttonMargin)*i), 1);
// Introduce our buttons one at a time
newClip.pressed = false;
// Trigger an event when our button is destroyed
newClip.onUnload = function()
{
var f = new Tween(this, "_alpha", Regular.easeOut, 0, 100, 2, true);
//var x = new Tween(this, "_x", Regular.easeOut, 0, 100, 2, true);
//x.continueTo(100, .33);
f.continueTo(100, .33);
}
// Trigger an event when our button is clicked
newClip.onPress = function()
{
// This is definitely not the way I wanted to do this, but it works for now...
curQuestion.SetOptionChosen( curQuestion.GetOptionAt( this.option_id.text-1 ) );
unloadMovie(this);
} //end onPress
// Trigger an event when we hover over this button
newClip.onRollOver = function()
{
var fOut = new Tween(this, "_alpha", Regular.easeIn, 100, 0, 0, true);
fOut.continueTo(0, .33);
var fIn = new Tween(this, "_alpha", Regular.easeIn, 0, 100, 0, true);
fIn.continueTo(100, .33);
} //end onRollOver
} //end for loop
}