Tuesday, September 29, 2009

Lesson 2

Lesson 2
- functions
- dynamic variables
- regular functions
- for loops
- arranging clips with for loops
- Math.random
- pythagorean theorem for scale
- drawing with code (lineStyle and lineTo)

Reading:
gravity tutorial
grids arranging clips

Pythagorean Theorem.... you don't have to read this, but I figured I'd put it in the links:
http://en.wikipedia.org/wiki/Pythagorean_theorem

Download Classfiles

Function Homework:

Add at least one function to your homework from last week...

Write all of the following functions... Use google to find conversion formulas for things like fahrenheit to kelvin:
http://www.google.com/search?hl=en&client=safari&rls=en&q=1+fahrenheit+to+kelvin&aq=f&oq=&aqi=

// scales a given movieClip's x and y scale properties to the same value
// takes 2 arguments, the clip to alter and the new scale value
uniformScale(myClip, .5);

// causes a given movieClip to rotate and animate off of the right
hand side of the screen.
// takes 3 argumets, the movieClip to alter, the rotation speed and
the horizontal velocity (x increment)
rollToRight(myClip, 10, 5);

// causes a given movieClip to scale up and fade out.
// takes 2 arguments, the movieClip to alter and the speed at which to fade and scale
scaleUpFadeOut(myClip, .1);


Conversion/Math:

// converts fahrenheit to kelvin - (temperature);
// takes one argument, the degrees in fahrenheit
// returns degrees in kelvin
tempFtoK(32);

// converts kelvin to fahrenheit- (temperature);
// takes one argument, the degrees in kelvin
// returns degrees in fahrenheit
tempKtoF(32);

// do the same for millileters to fluid ounces, and fluid onces to millileters


// calculates the area of a rectangle:
// takes 2 arguments, width and height of the rectangle
// returns the area of the rectangle
area(10, 20);

// adds 3 numbers together
// takes 3 arguments and adds them together
// returns the result of the addition of the three arguments
add3(100, 20, 300);

BONUS (optional - don't waste too much time if you can't figure these out):

// calculates the volume of a cube
// takes 1 argument, the length of any side of the cube
// returns the area of the cube
area(100);

// causes a given movieClip to fade out if it is clicked on
// takes 2 arguments, the movieClip to alter and the speed at which to fade out
fadeOutOnClick(myclip, .1);

// draws a grid of circles
// takes 3 arguments, number of rows, number of columns and spacing
// read the grids arranging clips tutorial first for this one
drawCircleGrid(10, 10, 3);

17 comments: