1. Home
  2. Computing & Technology
  3. Animation

Flash “Coloring Book” with setRGB

By Adrien-Luc Sanders, About.com

7 of 10

We want all of this to happen when the color is chosen by the user, and since the default method of user action is a mouse click, we’ll need an on (release) function:

on(release) {
_root.hue = 0x000000;
}

What this code does is define a variable named hue on the root level of the stage, and then set the value of hue to 0x000000 – which translates into black. When using hexadecimal values for colors in ActionScripting, always precede them with 0x instead of the # that you would use in HTML. So if we were working with red, we’d take the hex value for red – FF0000 – and turn it into 0xFF0000.

Don’t forget to put the _root. in front of the variable name; we’re going to be referencing this variable from another symbol, so we’ve got to make sure that it and the level that it operates on are clearly defined.

Explore Animation
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Flash “Coloring Book” with setRGB

©2009 About.com, a part of The New York Times Company.

All rights reserved.