1. Home
  2. Computing & Technology
  3. Animation

Deconstructing the Paint Application IX: Brush Size and Opacity Sliders

By , About.com Guide

6 of 6

Now again, I'm not going to break that code down line-by-line. But here's an overview of what it does:

First of all, the code is assigned to a controller movie clip off the visible area of the stage - it just exists to hold this code so we can use onClip(Event) handlers based around the movie clip loading or cycling through its single frame. I usually just draw random shapes and make movie clips out of them.

Each time the clip cycles through its single frame, Flash checks the x and y position of each slider and assigns it to one of four individual variables. Then the x position is compared to the starting x position set when the movie loaded, and if it's less, then the stopDrag command is used to stop the motion of the slider and reset its position to an acceptable place.

It's also tested to see if it's greater than the ending position (this is in the case of the brush slider; the opacity slider would go in reverse, as it would start at 100 and move backwards) and if it is, stop the slider's motion and then reset it to the greatest acceptable ending point.

Then it checks the y position, and if it's greater than or less than the starting y position, it resets it so that it can't rise higher or lower than its starting point. And that's it for the sliders.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

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

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Deconstructing the Paint Application IX: Brush Size and Opacity Sliders

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

All rights reserved.