People seemed to do pretty well on yesterday’s quiz. I have lots of questions written that fall into that same category of being somewhere between beginner and intermediate level. I decided to write a trickier quiz for today. Tomorrow I’ll alternate back to some easier questions. This quiz is really more about operators and hex numbers than ActionScript…
Number of Questions : 5
Difficulty : Medium
Topic : Operators and Hexadecimal
var currentIndex:int = indexCanvas.getPixel(mouseX, mouseY);
if(currentIndex != 0xFFFFFF){
var currentBox:Array = info[currentIndex]
redRect.visible = true;
redRect.x = currentBox[0];
txt.y = redRect.y = currentBox[1];
if(mouseX <txt.width){
tf.align = TextFormatAlign.LEFT;
txt.defaultTextFormat = tf;
txt.x = redRect.x + 10;
}else{
tf.align = TextFormatAlign.RIGHT;
txt.defaultTextFormat = tf;
txt.x = redRect.x - txt.width;
}
txt.text = currentBox[2];
txt.visible = true;
}else{
redRect.visible = false;
txt.visible = false;
}
}
This is a simplified example of the technique discussed in yesterdays post. The idea is to use a BitmapData image to store index values for a large number of elements that need to be able to act as if the have MouseEvents. For a more detailed description of this technique see yesterdays post.