
Page 3 of 3
Radina Matic
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
View all articles by Radina MaticThe question is answered only if all three dragable objects are dropped on their respective targets (Venice on Ponte Rialto, Rome on Coloseum and Florence on Ponte Vecchio) and therefore if statement has three conditions to fulfill before it returns true and continues with counter. The "Reset" button it is little more complex than before because apart from clearing the comment, it implies putting all the dragable objects back in their initial position. For this to work we should use some variables to retrieve their original position, therefore this is the code for frame actions:
stop ();
venicex = getProperty("venice", _x);
venicey = getProperty("venice", _y);
romex = getProperty("rome", _x);
romey = getProperty("rome", _y);
florencex = getProperty("florence", _x);
florencey = getProperty("florence", _y);
first = 1;
Then "Reset" button simply uses setProperty action to reset all objects to their initial position:
on (release) {
setProperty (_root.venice, _x, venicex);
setProperty (_root.venice, _y, venicey);
setProperty (_root.rome, _x, romex);
setProperty (_root.rome, _y, romey);
setProperty (_root.florence, _x, florencex);
setProperty (_root.florence, _y, florencey);
comment4 = "";
}
Keyframe 6 - Hot Region type of question
The last frame is similar to Hot Objects question but adds some graphic elements. I duplicated my original Italy map and divided it into 3 parts (regions), added some outer glow (just a way to highlight it on users click - you can achive this in millon different ways) and converted each part into a movie clip symbol. Then I put a transparent button with original region size (without glow) in the first frame of each movie clip, and finaly put the clips on top of the original map so they covered it completely. The last element is movie clip with small red spot which points out exact position of city of Bari, and becomes visible when check is performed after user choses the right region. When a user enters the frame for the first time all "Hot Regions" and Bari spot are set invisible in the frame actions:
stop ();
setProperty ("north", _alpha, 0);
setProperty ("south", _alpha, 0);
setProperty ("center", _alpha, 0);
setProperty ("bari", _alpha, 0);
first = 1;
The buttons inside every "Hot Region" should turn on visibility of the selected region and turn off the other two (see picture for actions in "north" transparent button).
Again the "Check Answer" button consults the variable that retrieves the visibility of the correct region (instance "south" in my case), triggers the counter if it was the first click, makes Bari spot visible, and displays feedback in the input text field:
on (press) {
good = getProperty(_root.south, _alpha);
if (good == 100) {
if (first == 1) {
first = 0;
result += 1;
}
setProperty (_root.bari, _alpha, 100);
comment5 = "Yes! Bet you've been cruising Mediterranean!";
} else if (good<100) {
comment5 = "You were sleeping on geography classes, not so?";
first = 0;
}
}
Keyframe 7 - Results
Final frame contains no symbols, just a text field which shows the percentage of correct answers and funny suggestion depending on how well the quiz went. All code is in the frame actions:
stop();
finalresult = int((result/7)*100);
if (finalresult<40) {
comment6 = "You got only "+finalresult+" % "+"of the answers right."
+ "Maybe you could use a study-vacation to, let's say,"
+ "nice italian monastery?";
} else if ((finalresult>30) && (finalresult<70)) {
comment6 = "You got "+finalresult+" % "+" of the answers right. Not bad"
+ ", but still improvable. Try hanging out with some Italians.";
} else if (finalresult>70) {
comment6 = "You got amazing "+finalresult+" % "+"of the answers right. "
+ "You deserve a nice vacation to, let's say, Island of Capri.";
}
// Note the above code has been split up
// to fit this tutorial template better
There are a lot of variations you could apply to the scripts I've proposed here. For example, the counter could be set to be much more precise, it could count second answers but weight them differently. The "next" button could be scripted to allow transition to the next question only after certain number of tries... You could set a button to start sound of the word(s) which user is then supposed to write in the input text field (kind of dictation)... Possibilities are limitless, everything depends on our creativity.
Hope this helps some of you who are interesting in using Flash for educational purposes. Happy flarning folks!
