1. Computing & Technology

Discuss in my forum

Flash “Coloring Book” with setRGB

By , About.com Guide

10 of 10

Flash “Coloring Book” with setRGB
Let’s use on(release) and setRGB again, only this time without having to define a variable:

on(release) {
fillshade = new Color (_root.rightarm) ;
fillshade.setRGB(_root.hue) ;
}

What this has done is define another new color function, fillshade, and assigned it to the instance on the stage named rightarm. Now Flash knows that when the mouse clicks and then releases on that fill, it needs to change the RGB value to the hex value of _root.hue – which, you’ll recall, we set up on the palette to change to whatever color we click on. This is why we needed to make sure that the variable was defined as _root.hue and not just hue, so we could call it from inside another movie clip’s ActionScripts.

Repeat this for each fill area, just changing the instance name where the new color is defined, and you should be done and ready to paint. Click here to see the preview version and how it should work. Or, if you’d like a bit more visibility, the massively, insanely large version is here.

©2012 About.com. All rights reserved.

A part of The New York Times Company.