
Page 2 of 3
Keyframe 3 - "True or False" type of question
This frame is bit more complicated because it has more scriptable elements. There is the usual invisible input text field for feedback with variable "comment" (don't forget to name every input text field in your movie differently, otherwise you'll be giving user a feedback in previous frame he/she can not see anymore), two plain buttons for True and False answers and 2 instances of movie clip "spot" (tiny black spot which appears when user selects one of the answers) laying one on the top of every button. The spots should be invisible when user first enters frame so each of them has the script you can see in the picture:

Spot becomes visible when user presses the button under it. To prevent both spots becomming visible at the same time (user is supposed to choose just one), actions on the button should make just one spot visible and the other invisible. I named the spot instances "truespot" and "falsespot" and this is the script for "True" button:
on (release) {
setProperty (_root.truespot, _visible, 1);
setProperty (_root.falsespot, _visible, 0);
}
The logic here is simple: if a user presses the button corresponding to the right answer, the spot instance belonging to that button will become visible and all the "Check Answer" button should do is make sure if the right spot instance is visible or not. For this we introduce a variable "right" which is set by getting the property visibility from the spot instance of the right answer (in my movie it was "false" spot). This is the script for "Check Answer" button:
on (release) {
right = getProperty(_root.false, _visible);
if (right == 1) {
if (first == 1) {
first = 0;
result += 1;
}
comment2 = "Yeah, because they are still too 'young' to flee the nest...";
} else {
comment2 = "No, most of them stay with their mammies until over 30...";
first = 0;
}
}
The "Reset" button will set invisible both spot instances and clear the comment field as in previous frame:
on (release) {
setProperty (true, _visible, 0);
setProperty (false, _visible, 0);
_root.comment2 = "";
}
Keyframe 4 - Hot Objects type of question
Even more elements here! We need 4 instances of movie clip "bandiera" each one with different orientation (I named them flag1, flag2...), and since they should be "hot" we'll have to put a transparent button with the same dimensions on top of each of them. In this case transparent button triggers alpha property of the movie clip under it when selected by user:
on (press) {
setProperty (_root.flag2, _alpha, 100);
setProperty (_root.flag3, _alpha, 100);
setProperty (_root.flag4, _alpha, 100);
setProperty (_root.flag1, _alpha, 30);
}
As in the "true-false" frame, by clicking on one transparent button, the flag instance under it becomes "a bit" invisible, while the rest of flag instances remain fully visibles, so only one of them can be chosen at the time. "Check Answer" button works the same way - it checks alpha property of right answer through a variable and if it is correct (on first click), goes on with counting and displaying the comment in the usual text field:
on (press) {
good = getProperty(_root.flag1, _alpha);
if (good<30) {
if (first == 1) {
first = 0;
result += 1;
}
comment3 = "Whoo!!! You're real expert on italian matters...";
} else if (good>30) {
comment3 = "Sorry, no luck!";
first = 0;
}
}
Keyframe 5 - Drag and Drop type of the question
For this frame we need three dragable objects (movie clips with a transparent button in the first frame - for more details see this tutorial) and three target movie clips. Name all instances on stage and put this code in the "Check answer" button:
on (press) {
if ((_root.venice._droptarget == "/ponterialto") && (_root.rome._droptarget ==
"/coloseum") && (_root.florence._droptarget == "/pontevecchio")) {
if (first == 1) {
first = 0;
result += 1;
}
comment4 = "Strong in italian architecture too, ah?";
} else {
comment4 = "Bet you didn't pay attention during art history classes in school!";
first = 0;
}
}
