Multimedia Programming

312-100

Lab 5

Part 1

Due: Monday, 28 February, 2000, beginning of class.

Complete the following activities. You may work in pairs. Be sure to put your three movies into a folder labeled with the last names of the people doing the lab. Then drag the folder into the Turn-In:Lab 6 folder.

You must also provide written answers to the questions in activity 1. Hand these in on a sheet of paper on the due date.

  1. Activity 1. This activity involves the creation of a movie with user input fields. A completed activity two movie is available as a projector in the Materials folder.

    1. Open a new movie and make the background some color.

    2. Create two fields using the Tool Palette. Make the font in the fields to be Monaco, 24pt, bold. The text should be colored.

    3. Give the fields names "xField" and "yField".

    4. Make sure that the two field sprites are in frame 1 and make sure that they are both editable and have background transparent ink.

    5. Put the fields side by side and make a large X (i.e., a times symbol) using the text tool and put it in between the two fields. Make sure that neither field covers the X. Use Modify/Align to ensure that the Top location of all three sprites is the same.

    6. Now create a third field and name it "result". This field should not be editable. Put this field on line with the other two fields. Create a large equal sign in the Paint window and place it between the second field and the third field. Frame 1 of your movie should look something like this:

      Field "x"	X 	Field "y"	=	Field "result"
      

    7. Next create a colored button. Give it the title "Calculate".

    8. Now create a Sprite script for the button that says:

      on mouseUp
      	set x = field "xField"
      	set y = field "yField" 
      	set z = x * y 
      	put z into field "results"
      end
      

      The letters x, y, and z are called variables. The are just the names of memory locations that can hold values, in this case numbers. They don't appear in the cast, but only exist in the computer's memory. The line set x = field "xField" takes the value stored in the field "xField" and stores it in the variable x . The next two lines perform similar actions. The last line places the result of the multiplication into the "results" field.

    9. Put the following script into frame 1:

      go to the Frame

      "the Frame" returns the value of the current frame. Thus this script tells Director "go to frame 1". This is yet another way of creating a loop.

    10. Now play the movie. You should be able to enter numbers into the xfield and yfield and then click on the "Calculate" button and see the results in the "results" field. Note: you can make the fields "tabbable" by going into the cast member property for each field and checking the appropriate box. If a field is tabbable, hitting the tab button while in a field will cause the cursor to go to the next field on the stage.

    11. Next, we'll initialize the two input fields to 0. Create a movie script and place the following script in it:

      on startMovie
      	put 0 into field "xField"
      	put 0 into field "yField"
      	put 0 into field "results"
      end
      

    12. Now, we'll make the movie interactive. Create text at the top of frame one that says "Enter your name:". Next to this put an editable field with the name "theName".

    13. Change your startMovie script to also initialize the field "theName" to have the value "Name".

    14. Create on last field and place it below your equation. Name this field "response".

    15. Add to the "Calculate" button script the following line:

      	set aName = field "theName"
      	put aName & ", the answer is: " && z into field "response"
      

      The first line creates a variable named "aName" and places the value of field "theName" into it. Next it concatenates the value in the variable "theName" to the string "the answer is:" to the value stored in variable z and then puts everything into the field "response".

    16. Initialize the field "response" in the movie script by putting a blank into it, i.e., put " " into the field.

    17. Finally, create a button named "Clear" that puts "Name" into the field "theName", 0 into the fields "xField", "yField", and "results" and a blank into the field "response".

    18. Test your movie. Note that you can go from field to field by hitting the tab key.

  2. Activity 2. This activity shows you how to change sprite properties such as the member and the visible.
    1. Open a new movie. Call it "your last name lab 5 part 2" or something similar.

    2. Create 4 different cast members (cast members 1 through 4). Place two of these cast members (cast members 1 and 3) into the score.

    3. Make the movie last about 28 frame and then loop by putting a script on the last frame of your movie. Make sprite 1 move from left to right and make sprite 2 stay in one place.

    4. On the moving sprite, put the following script:

      on mouseDown
        if the memberNum of sprite 1 = 1 then
      	set the member of sprite 1 to 2
        else
      	set the member of sprite 1 to 1
        end if
      end
      

      The property memberNum is the number of the cast member that currently occupies sprite 1. The property the member identifies both the number of the cast member that currently occupies sprite 1 and the cast that the member comes from (a movie can have multiple casts). Thus we cannot use the member in the test condition of the if statement.

    5. Now if you click on sprite 1 as it moves across the stage, it will change to cast member 2. The next time you click on the sprite, it will change back to cast member 1, etc.

    6. On the stationary sprite (sprite 2) put the following script:

      on mouseEnter
        set the member of sprite 2 to 4
      end
      
      on mouseLeave
        set the member of sprite 2 to 3
      end
      

    7. Now create a cast member that contains the words "You got me!". Make sure that this is cast member 8. You can move cast members around if you need to.

    8. Place cast member 8 into channel 3 so that it becomes sprite 3.

    9. Now create a movie script. To do this, click on a blank square in the cast. Then choose Script from the Window menu. Type in the following script:

      on startMovie
        set the visible of sprite 3 to false
      end
      

      This will make sure that sprite 3 is invisible when the movie starts.

    10. Now change the script on sprite 1 to read:

      on mouseDown
        if the memberNum of sprite 1 = 1 then
      	 set the visible of sprite 3 to true 
      	set the member of sprite 1 to 2
        else
      	 set the visible of sprite 3 to false 
      	set the member of sprite 1 to 1
        end if
      end
      

      Now, when you click on the moving sprite, it should change cast members and the text should appear. When you click on the moving sprite a second time, the cast member should change back and the text should disappear.

    11. Next we'll change the cursor. First we'll create a cursor. Start a new cast member. Draw a 16 by 16 pixel cast member with only one color. Close the paint window.

    12. Turn the cursor that you just made into a 1-bit graphic. To do this, click on the cursor in the cast window. Then choose Transform Bitmap from the modify menu. In the resulting dialog box, choose 1 bit and then click OK. Answer the next question by clicking OK.

    13. Name your cast member "newCur" by clicking on the cursor cast member in the cast window and then typing "newCur" in the white box at the top of the cast window.

    14. Now create a new script for sprite 2 by using the popup menu in the score. Note that this script not only changes the cursor, but it also changes the member of the sprite. In this script put:

      on mouseEnter
         set the member of sprite 2 to 4
         cursor [cast "newCur"]
      end
      
      on mouseLeave
         set the member of sprite 2 to 3
         cursor -1
      end
      

  3. Activity 3. Creating movies that play movies. In this activity you will create a movie that has two buttons. The first button will play the movie created in the first activity and the second button will play the movie from the second activity.

    1. Create a new movie. Place some color in the background.

    2. Put two buttons in the movie. Name the first button "Activity 1" and the second button "Activity 2".

    3. Loop the movie in frame 1.

    4. Put a sprite script in the "Activity 1" button that says:

      	Play movie "theNameOfYourFirstMovie"
      

      where "theNameOfYourFirstMovie" is the actual name of your first movie.

    5. Give the "Activity 2" button a similar script that calls the movie from the second activity.

    6. Save this movie and open the movie from activity 1. Add a button named "Return" that has the script:

      	on mouseUp
      		Play done
      	end
      

    7. Save this movie and open the movie from activity 2. Put a "Return" button in this movie that contains the same script.

    8. Save the second movie and open the third movie. Test the movie and make sure that you can to to the activity 1 movie and the activity 2 movie.

PostLab 5

Due: Friday, 14 July 2000 at the beginning of class.

Note that you must work individually on the post lab.

Turn in a movie not a projector .

All movies must have an opening sequence that lists the name of the person involved in the lab. Keep a copy of your movie; you will be modifying this movie in a later lab. This movie is a modification of the last postlab.

  1. Create a movie with an opening scene and two other scenes or "games".

  2. In the opening scene have three buttons, a halt button and two buttons to take the player to the two games.

  3. One game should consist of 4 or 5 moving objects. Every object should move across the stage (up to down, down to up, right to left, or left to right) but no object should have a straight path. Also no object should move at a uniform rate across the stage, ie, objects should speed up or slow down as they move. When the player clicks on an object the movie should play a sound. The sound cannot be the "beep" sound, but must be a sound from the cast. Every object must have a different sound. This game must have a button that takes you back to the opening menu.

    In addition, you must have two fields with lables. The first field will be labeled "Tries" and the second field will be labeled "Score". Whenever the player clicks and hits a moving sprite, the score must increase by 1. Whenever the player clicks (regardless of whether she hits a sprite or not), the value in the "Tries" field must increase. When you begin the movie, both fields must start out at 0.

  4. The second game will be a question and answer quiz. Put one question on the stage. Have three buttons beside possible answers. If the user clicks on the correct choice, increment a score field by 3 points (this field must be initialized to 0 when the game begins). If the user clicks on a wrong answer, decrement the score by 2. Make sure that there is a button that takes the user back to the menu frame.

    Last Modified: 11 July 2000

    THIS PAGE MAINTAINED BY:
    John Barr, Ithaca College