Project 4 Redo

May 11, 2010 |  by  |  Project Four, Student Work, Tutorial

For my redo of project 4, I decided to improve my knowledge of actionscript 3 using a set of Cartoon Smart’s tutorials for constructing flash games. Prior to taking on this challenge, I was really struggling with code, so it made sense to try to do something that would force me to interact with the more complicated aspects of actionscript. I ended up getting more than I bargained for.

Project Objectives

  • To improve my understanding of actionscript of a whole
  • To learn some of the elements of code that allow for multi-player games and how to toggle back and forth between players
  • To improve my understanding of complex conditional statements
  • To move my coding to the next level (which, given that before I could only fade things in and out, is not saying much)

Project Outline

  • To work through a couple of Cartoon Smart tutorials, starting with one on controlling objects on the stage using actionscript alone and working my way up to doing a complex game, in which I am certain to encounter complex actionscript.
  • Using the knowledge that I absorb from doing the complex game, to construct a simpler game of my own (without a tutorial as a guide). With this second step, I will hopefully be transforming passive knowledge into active knowledge.

Step 1: Follow a Tutorial, Construct a Game

First of all, let me start out by saying that I got a little bit more than I bargained for, but I think I managed to learn a lot more than I was expecting, as well, so things evened out in the end. For my complex game, I chose to follow the tutorial for a darts game (which actually ended up being three darts games in one. I worked my way through some really complex code, and it was a major moral victory when I finally got everything to work, even with a tutorial to work along with.  The tutorial came with a starter file, so I worked using Cartoon Smart’s artwork. Even so, just doing the code work was enough to keep me busy for days. The buttons at the beginning of the game and the end of the game are mine, however. I put those in myself and linked them to the appropriate variables to allow the user to select which game he/she wanted to play.

Things I learned (This is a shortened list; I learned more things than I could keep track of):

  • How to include external as3 code, allowing me to separate my code, while still making the individual sections findable through naming conventions.
  • How to create variables and apply mathematical functions to them so that the speed of objects varies in a nonlinear way.
  • How to use and customize the sliders component
  • How to use an ENTER_FRAME event listener.
  • How to create a two player game and keep the two scores separate from each other. Also, how to build turn alternation into the game.
  • How to trigger functions outside of an event listener.
  • How to remove event listeners inside of functions to prevent double triggering and bugs in the code.
  • How to create tweens using code, pre-TweenMax (which helped me understand TweenMax better).
  • How to use filters inside of flash.
  • How to construct complex conditional statements
  • And many other things that I’ve forgotten to list here. Overall, my understanding of how actionscript is structured and how to write functions so that they are triggered in the appropriate order/at appropriate times was greatly improved.

Without further ado, here’s my SWF:

Step 2: Use what you just learned, and build your own game, sans tutorial

Despite having just worked through a much more complicated more game with a tutorial as a guide, I was amazed at how difficult it was to sit down and write the code for a completely different sort of game from scratch. I managed, but it was not without a lot of errors and failed attempts.

For my own game, I built Tic Tac Toe. Even though it’s a very simple game, it still took a lot of code to construct and make work the way it’s supposed to. You have to construct code that will take into account every single possible move that a user could make and every single possible outcome. It was a lot more difficult than I thought it would be, and definitely much different from working witha  tutorial.

Outcomes of Step 2:

  • Practiced working with masks and cuing different movie clips
  • Understood in a much more concrete way how to construct a scoring function and run it between turns.
  • Practiced working with event listeners inside of event listeners. Learned about some of the errors that can come up and how to work around them.
  • Practiced triggering functions inside of functions.
  • Worked in some more complex action script and wrote some complex conditional statements.

And here’s my second SWF:


Overall, I think that I was very successful with trying to meet my project goals. Looking at my four objectives, I think I met all of them. I know I definitely worked through a lot of the issues that I was having with actionscript at the beginning of the semester. I have a much more solid understanding of it and I’m much less frustrated with Flash than I was at the start of the semester.

Constructing the games was a good solution for me and my Flash-induced-frustration because I got to play the game every time I wanted to see if something was working. When I was working through my errors in the darts game, I was sitting in the Newhouse labs with a friend who was working an overnight shift, and every time I got through with a possible correction, she and I would play it together to see if it was working. It was really fun, and took some of the pain out of the learning process for me. I would highly recommend games to other people who struggle with actionscript; they’ll definitely help you learn and understand more, without the frustration that surrounded trying to gain an understanding of actionscript through other means.

I’ve attached my files (with commented actionscript) below, so you guys can check them out (and hopefully learn from them as well). To those of you who are going home (or have already gone home), I hope you have a great summer!

Darts files | Tic Tac Toe Files | Cartoon Smart website