Welcome to CSC 130
In this lab, you'll learn about the basic objects we'll be using throughout the term, and the environment we'll be using for teaching, development, and experiment. To start: you are (obviously) looking at a web page. But it's a special web page: everything is changeable, everything is live. To see this, first, pick up the rectangle and move it around.
More than that, every piece of text is potentially executable. Try clicking on this: Change My Color!
Welcome to CSC 130
Well, you have seen that before. But when you clicked on that text, what actually went on was that the text sent a message to the Rectangle to change its color. We can also do that. Select the following text and click 'cmd-d' (Mac) or 'ctrl-d' (Windows/Linux):
$morph('example-rectangle').changeColor()
If you look in the upper left corner, you'll see three tiles with the words "Morphic", "Graphics", and "JavaScript" on them. Click and drag "Morphic" and you'll get a copy attached to your cursor. Go ahead and drop it on the rectangle. the 'state' tab is selected by default and shows you the properties of the morphic object you dropped it onto. We will discuss this in more detail in a moment, but for now, click on the behavior tab. This brings up the list of scripts attached to the morph. notice that the changeColor script is listed. Click the '!' next to the name to execute it. To make it repeat, click the square beside it and enter the number of milliseconds between executions. Clicking the same box stops the repetition
That was an example of sending a message (changeColor) to an Object (the rectangle). In fact, it was really sending two messages to two different objects. The first message, $morph was sent to the world -- it said "find me an Object named example-rectangle". The world then returned the rectangle, and we told it to change color.
Let's try sending some other messages. How about:
Sending Messages