Flash Homework

If you want to compile and run Flash applications on your own computer, follow our Flash/Flex Installation Instructions.

icon Turn in HW5 here. Flash Homework 5 (Eater)

"Due" Sunday, August 15, 11:30pm (see below).

Spec:

Write an ActionScript program Eater.as that draws squares on screen at random intervals between 0 and 2 seconds. All squares on screen should decrease until their size is less than 2 pixels at which point they should be removed from the screen entirely. Additionally, you should draw a circle on the left of the stage. This circle will automatically move to the left but its direction can be changed with the arrow keys. When this circle hits any square that is on screen this square should change size to 30x30 and should follow the circle around the board. If more than one square is following the circle then they should follow in a line. If the circle collides with either a wall or one of its collected squares the game should reset to the previously described beginning state. There should also be a score field that displays the score computed however you see fit. The solution score is simply the number of squares collected.

You can set up your computer to compile/run Flash programs as described in our Flash installation instructions. At first you can test your program by compiling it into a .swf program and double-clicking that .swf file on your machine to run it. But eventually you should create a file eater.html in which to embed the Flash SWF program. Use the object tag to place the Flash movie into the page. Turn in both your .as file and your .html file. You may also turn in an optional CSS file if you like.

Development Strategy:
  1. You are probably starting from the code used in Flash HW4. Therefore you should be keeping track of the squares that are on screen with two arrays, one for the squares that have yet to be collected and one for those that have been collected.
  2. Create and update the score field as necessary.
  3. Make it so that colliding with a wall restarts the game.
  4. Make it so that colliding with an already collected square restarts the game. This can be tricky. If there isn't a small bit of space between the circle and the first square because upon collecting a square they will be colliding. For this reason you should ensure that the collected squares and the circle are seperated by at least a pixel.
  5. Add whatever other polish you want. You just wrote Snake!!!
Reward:
  • If you turn it in by Sun August 15 11:30pm, we will give you up to +1 late Days.
Expected Output:
Links:

icon Turn in HW4 here. Flash Homework 4 (Collector)

"Due" Sunday, August 8, 11:30pm (see below).

Spec:

Write an ActionScript program Collector.as that draws squares on screen at random intervals between 0 and 2 seconds. All squares on screen should decrease until their size is less than 2 pixels at which point they should be removed from the screen entirely. Additionally, you should draw a circle on the left of the stage. This circle will automatically move to the left but its direction can be changed with the arrow keys. When this circle hits any square that is on screen this square should change size to 30x30 and should follow the circle around the board. If more than one square is following the circle then they should follow in a line. You are implementing the essential functionality of the arcade game Snake.

You can set up your computer to compile/run Flash programs as described in our Flash installation instructions. At first you can test your program by compiling it into a .swf program and double-clicking that .swf file on your machine to run it. But eventually you should create a file collector.html in which to embed the Flash SWF program. Use the object tag to place the Flash movie into the page. Turn in both your .as file and your .html file. You may also turn in an optional CSS file if you like.

Development Strategy:
  1. You are probably starting from the code used in Flash HW3. Therefore you should be keeping track of the squares that are on screen with an array. This array contains all squares and is used to update the squares' size.
  2. Keep track of the direction that the circle should be moving in with a Point object. You can use this direction when you move the circle.
  3. When the circle touches a square you should remove that square from your array and place it in a second array. This array will keep track of the squares that are following the circle. You should also move the square to be behind the circle in the direction it was moving.
  4. Create a new array that will keep track of the history of movements of the circle. So everytime you move the circle you should add its direction to this array.
  5. If we move the squares in the same direction as the circle then we actually get a clump that moves. This isn't actually what we want. What we really want is for the first square in the train to move in whichever direction the circle moved last time. We want the second square in the train to move in the same direction that the circle did two times ago. Luckily you have an array that keeps the history of the moves. When you move the squares use the cooresponding direction stored in this history array.

You may find the splice, unshift, and pop methods of Arrays helpful

Reward:
  • If you turn it in by Sun August 8 11:30pm, we will give you up to +1 late Days.
  • If you turn it in anytime after that, we will give you up to +1 early days.
Expected Output:
Links:

icon Turn in HW3 here. Flash Homework 3 (Dodger)

"Due" Sunday, August 1, 11:30pm (see below).

Spec:

Write an ActionScript program Dodger.as that draw a square on screen at random intervals between 0 and 2 seconds. All squares on screen should decrease until their size is less than 2 pixels at which point they should be removed from the screen entirely. Additionally, you should draw a circle on the left of the stage that can be moved around with the arrow keys. When this circle hits any square that is on screen he should be moved back to the left of the stage. It is heavily encouraged that you use your code from assignment 2 as a starting place for assignment 3. Stick with the next three flash assignment and you will have an awesome game to show for it!

You can set up your computer to compile/run Flash programs as described in our Flash installation instructions. At first you can test your program by compiling it into a .swf program and double-clicking that .swf file on your machine to run it. But eventually you should create a file dodger.html in which to embed the Flash SWF program. Use the object tag to place the Flash movie into the page. Turn in both your .as file and your .html file. You may also turn in an optional CSS file if you like.

Reward:
  • If you turn it in by Sun August 1 11:30pm, we will give you up to +1 late Days.
  • If you turn it in anytime after that, we will give you up to +1 early days.
Expected Output:
Links:

icon Turn in HW2 here. Flash Homework 2 (Expander)

"Due" Sunday, July 25, 11:30pm (see below).

Spec:

Write an ActionScript program Expander.as that draws a rotating square in the center of the screen. When the up key is pressed this square should increase in size. When the down key is pressed the square should decrease in size.

You can set up your computer to compile/run Flash programs as described in our Flash installation instructions. At first you can test your program by compiling it into a .swf program and double-clicking that .swf file on your machine to run it. But eventually you should create a file expand.html in which to embed the Flash SWF program. Use the object tag to place the Flash movie into the page. Turn in both your .as file and your .html file. You may also turn in an optional CSS file if you like.

Extra Feature:

For an extra reward do all of the above, but then also, when the space bar is pressed, have another randomly positioned square appear on the stage. All squares placed in this way, as well as the original square, should rotate and respond to the up and down keys by growing and shrinking in size respectively.

Reward:
  • If you turn it in by Sun July 25 11:30pm, we will give you up to +1 extra credit homework point. (Note that you cannot earn over 100% on the homework grading category as a whole.)
  • If you turn it in anytime after that, we will give you up to +1 extra late day.
Expected Output:
Links:

icon Turn in HW1 here. Flash Homework 1 (Spinner)

"Due" Sunday, July 18, 11:30pm (see below).

Spec:

Write an ActionScript program Spinner.as that draws a rotating square that moves from side to side. When it hits the edges of the Flash object, it should reverse direction and move back the other way. The things presented in the first two flash sessions are enough to write this program, but you may use whatever you want.

You can set up your computer to compile/run Flash programs as described in our Flash installation instructions. At first you can test your program by compiling it into a .swf program and double-clicking that .swf file on your machine to run it. But eventually you should create a file spin.html in which to embed the Flash SWF program. Use the object tag to place the Flash movie into the page. Turn in both your .as file and your .html file. You may also turn in an optional CSS file if you like.

Reward:
  • If you turn it in by Sun July 18 11:30pm, we will give you up to +2 extra credit homework points. (Note that you cannot earn over 100% on the homework grading category as a whole.)
  • If you turn it in by Sat July 24 11:30pm, we will give you up to +1 extra credit homework point.
  • If you turn it in anytime after that, we will give you up to +1 extra late day.
Expected Output:
  • icon spin.html (our sample solution, view in FireFox)
Links:
Valid XHTML 1.1 Valid CSS! JavaScript Lint