Spring 2003
Example Questions
Exam 1
Consider the screen shot given below. Assume that the text cast member is
named “score”
the button is named “play”, and the second text cast member is
named “name”.
Give scripts to create the following interaction:
- What property of the sprite 3 (the “name” cast member) must you
change to make this
movie work and how must you change it?
When you click on the button, you must generate a random number. Put the die that
corresponds to the number on the stage. Play the sound “electronic bong”.
- If the result was a 4 or a 6, put “Name, you win! Number of tries is X”
into the
“score” field. Name should be whatever is in the “name” field
and X should be the
number of times that the “play” button was clicked since the movie was started.
- If the result was a 1 or a 3 put “Name, pay double! Number of tries is X” into
the “score” field. Name should be whatever is in the “name” field and X should be the
number of times that the “play” button was clicked since the movie was started.
- If the score was 2 or 5, put “Name, you lose! Number of tries is X” into the “score
field . Name should be whatever is in the “name” field and X should be the number of
times that the “play” button was clicked since the movie was started.
- Loop through this animation so that I can continue to play your game.
- There should be a Halt button in all the frames of this animation. If I click
on this button, the movie should halt but not quit. In other words, director should
still be running even though the movie halts.
- When the movie begins, the score must be 0 and the “score” field must display a
message such as no score, and the name field must say “no one”. Where must this
script be put? Write the script out.
Solution: put the following script in the play button:
on mouseUp me
global theScore
theScore = theScore + 1
theRoll = random(6)
sound(1).play(member("electronic bong"))
sprite(1).castNum = 35 + theRoll
if theRoll = 4 or theRoll = 6 then
member("score").text = member("name").text & ", you win! Number of tries is" && theScore
else
if theRoll = 1 or theRoll = 3 then
member("score").text = member("name").text & ", pay double! Number of tries is" && theScore
else
member("score").text = member("name").text & ", You lose! Number of tries is" && theScore
end if
end if
end
Last
updated on February 27, 2003 by
John
Barr
|
 |