Making a Coloring Book (the Code for this is in the file - "ColoringBook.LiveCode" below) You can easily make a coloring book with buttons and graphics objects. We are going to have buttons with different colors on them. When you click on one of them, you will "pick up" their color and what ever you click on after that, will be colored the same color.
On the "Tools Palette" Use these graphics - square, circle, oval and polygons It should now look like this: Make Sure that each object has the "Opague" box checked And add the following code to every object that you added: global x on mouseUp set the backColor of me to x end mouseUp ------------------------------------------------------- Advanced Code -------------------------------------------------------- As you add more objects, you will have to add this code to every object and it is all the same code. But there is a shortcut!!! We could put the following code on the card instead (and not put any code on each object) global x on mouseUp set the backColor of the target to x end mouseUp When LiveCode has a message, like mouseUp, it looks on the object for the code for it. If it does not find any code for the mouseUp message, it then looks on the card. If it does not find any code there, it then looks on the stack. In other words, it looks up the "message chain" for the code for the mouseUp message.
Notice that we changed the code a little. We made it use the 'target' instead of 'me' When the code was on the object, it was 'me'. Now that the code is on the card, it does not want to use the color of 'me' which is the card. It wants to use that of the 'target' of the object that you clicked. Look up the "message path" in the lessons to find out more ------------------------------------------------------- Advanced Code -------------------------------------------------------- It should now look something like this: |
Home >





