Hey All,
Banging my head against the wall…Here’s what I’ve got going on:
There are three questions. If a user hovers over a question, the answer to that question pops up.
What I’m having trouble with is: I want the non-hovered-over questions to dim to 50% alpha, while the hover-over question is always 100% alpha. Currently I’m trying to use an array and reference the values beside it and then dim those values. Can I somehow make it so that when the array hits the end it wraps around back to the beginning and when it hits the beginning it wraps around to the end? Maybe there is a better way to do this alltogether, I’m just not there. Please help! Thanks!
var answers_array:Array=[answerOne,answerTwo,answerThree];
var questions_array:Array=[questionOne, questionTwo, questionThree];
for(var i:int = 0; i < questions_array.length; i++)
{
questions_array*.addEventListener(MouseEvent.MOUSE_OVER, showAnswers);
questions_array*.addEventListener(MouseEvent.MOUSE_OUT, hideAnswers);
}
function dimQuestions (indexID1, indexID2) {
questions_array[indexID1].alpha=0.5;
questions_array[indexID2].alpha=0.5;
}
function lightQuestions (indexID1, indexID2) {
questions_array[indexID1].alpha=1;
questions_array[indexID2].alpha=1;
}
function showAnswers(e:MouseEvent)
{
var index:int = questions_array.indexOf(e.target);
if(index != -1)
{
answers_array[index].alpha = 100;
dimQuestions((index+1),(index-1))
}
}
function hideAnswers(e:MouseEvent)
{
var index:int = questions_array.indexOf(e.target);
if(index != -1)
{
answers_array[index].alpha=0;
lightQuestions((index+1),(index-1))
}
}
//fix bubbling issues and set initial alpha of questions to 0
function setAnswers() {
{
for each (var answers_arrayID in answers_array) {
answers_arrayID.mouseEnabled=false;
answers_arrayID.answerBacking.mouseEnabled=false;
answers_arrayID.alpha=0;
}
}
};
setAnswers();