Hmwk 01 ... Hmwk 02 ... Hmwk 03 ... Hmwk 04 ... Hmwk 05

Homework 05 Kara Kronenwetter.
Specific Technique: Drawing API

Download Support Files: (kck_drawing_api_sample, 16k)

Presentation Outline:

1. Show working .swf
2. Go through all assets needed

  • Drawing area
  • Controls
  • Actions

3. Assign code to assets - explain

  • In Main Movie:

// If mouse button is pressed, set line style, start drawing.
_root.onMouseDown = function () {
      _root.actions.pendown = true;
      with(_root.drawingPlane){
            lineStyle( _root.actions.thickness, _root.actions.HEXcolor, _root.actions.cA);
            moveTo(_root.actions.lastX, _root.actions.lastY);
      }
}
// If mouse button is released, stop drawing.
_root.onMouseUp = function () {
      _root.actions.pendown = false;
}
stop();

  • Imbeded in Movie

onClipEvent(load){
      // Load default variables
      pendown = false;
      setting = false;
      thickness = 2;
      cR = 0;
      cG = 0;
      cB = 0;
      cA = 100;
      var HEXcolor;
      myColor = new Color(_root.cBlock);
}
onClipEvent(enterFrame){
      lastX = x;
      lastY = y;
      X = _root._xmouse;
      Y = _root._ymouse;
      HEXcolor = (cR << 16 | cG << 8 | cB);
      if(pendown && !setting){
            _root.drawingPlane.lineTo(X,Y);     
      }
      myColor.setRGB(HEXcolor);
      _root.cBlock._alpha = cA;
}

  • On Clear Button

on(release){
      _root.drawingPlane.clear();
}

  • On Thickness Button

onClipEvent(enterFrame){
      _root.actions.thickness = Math.floor(((_x - 96)*20.999)/80);
}

  • On Alpha Button

onClipEvent(enterFrame){
      _root.actions.cA = Math.floor(((_x - 96)*100.999)/80);
}

  • On RGB Buttons

onClipEvent(enterFrame){
      _root.actions.cR = Math.floor(((_x - 236)*255.999)/80);
}

4. Explain cursor change

  • On drawing area sized button

on (rollOver) {
         Mouse.hide(); startDrag("cursor", true);
          }
         
on (rollOut) {
          Mouse.show(); startDrag("blank", true);
          }

5. Wrap up