04
using instances

challenge

  1. use an instance of the Date object and trace to print the current time to the output window
  2. create an Array of three values, and trace the middle one to the output window.
  3. experiment with drawing lines of different thicknesses, colors, and opacities
    // import classes we want to use
    import flash.display.Graphics;
    import flash.display.Shape;
    
    // instantiate a new shape to draw in
    var canvas:Shape = new Shape();
    
    // add the shape to the display list so it appears on-screen
    addChild(canvas);
    
    // set the current linestyle to be 10px wide, red, and 50% opaque
    canvas.graphics.lineStyle(10, 0xff0000, .5);
    
    // draw a line from the left of the stage to the right
    var yPos:Number = stage.stageHeight*.5;
    var xLeft:Number = stage.stageWidth * .1;
    var xRight:Number = stage.stageWidth * .9;
    
    canvas.graphics.moveTo(xLeft, yPos);
    canvas.graphics.lineTo(xRight, yPos);
    
  4. try making different drawings on different key frames of the timeline. don't forget the stop() method of MovieClip.
  5. make use of the Date object to time how long it takes your machine to execute your multi-frame drawing experiment and print the duration to the output window