Activity 6: Timers

Intent

  • Students will learn to add a timer to a flash document to control the movement of the second hand on a stopwatch.
  • Import and size images.
  • Convert an image into a movie clip.

Criteria

  • Completion of the tutorial
  • Extension of the tutorial to add the movement of another object.

Task:

You will need the files stopwatch.jpg and hand.gif for this tutorial.

  1. Open a new Flash 3.0 document. You may use all of the presets.
  2. Import stopwatch.jpg to the stage. You will need to size the stopwatch. Change the width and height in properties. To change the size proportionately make sure the values are locked together. (See icon to the left of the width and height value)
  3. Import hand.gif to the stage. Size and position as you did in step 3.
  4. Convert the hand to symbol, type: MovieClip. Name the symbol hand.
  5. Change the instance name to hand in properties.
  6. In actions add the following the following code:
    var timer:Timer = new Timer(1000);
    timer.addEventListener(TimerEvent.TIMER, onTimer);
    timer.start();function onTimer(evt:TimerEvent):void {
    hand.rotation += 6;
    }
  1. Test the code. You may notice that the rotation point is in the wrong place. To correct this double click the hand to go into symbol mode. The rotation point is indicated with a plus sign. Maneuver the arrow so that  the center point located at the base of the arrow.
  2. Once the code is working experiment by changing the 1000  and 6 to different number values. What do each of these numbers represent?
  3. Add an hour hand to your stopwatch. (Hint, you may use the same timer)
  4. Post your completed application to your website