Tip:
Highlight text to annotate it
X
In this chapter I'm going to explain what functions are and how to use them. If you'd like to
follow along with this movie this file is in the chapter 3 Working Files folder
and it's called Functions.swf. So feel free to open that if you want to
follow along. A function is a reusable block of code. So
let's say this is a block of code right here, this big block in the middle
of the screen. And I want to modify properties of my boarder,
which is right at the bottom right of the screen. So I would drop the boarder inside
of the function to apply a function to the boarder.
I'm going to modify his rotation, and then modify his movement.
Now if I click run function, he'll move and rotate.
So let's just click this reset button and try again. I'm going to drag the boarder in
there, cause we need to apply to the boarder. And let's just say I want to only move him.
Run the function, moves, run the function, moves. Now let's say if I want to only rotate
the boarder. So I'm just going to toss the rotate block inside of the block of code,
and then run the function, and that will just rotate the boarder and not move
the boarder. So again a function is a block of code that
we can use over and over and over again. So let's learn how to write them in
the next movie.