Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

 

 

 
Color Object
       by senocular

What the color object does is allows you ways to apply color and alpha effects to movieclip objects much in the sense of a filter. When applied to a movieclip object, it is applied to everything within that movieclip. This includes all lines, all fills and any symbol that may exist within that movieclip, no matter what their color.

setRGB is an absolute color effect. Absolute in terms of, when set, the set color is the absolute or only color that the entire movieclip will possess (again this is for everything within that clip since everything inside is part of what makes that clip what it is).

setTransform allows more control with amounts of color added. In fact, there really doesn't even need to be a setRGB because it can be done just the same with setTransform. setTransform just gives you more options and is therefore, harder to use. What you can escape from with setTransform is, though, the whole absolute color deal, now being able to apply only subtle amounts of color to a movieclip, or even reversing the current color.

Now, these are methods of a color object. A color object is a controller of these 'filters'. Its not itself a filter. The color object is more like the pull-down menu you open to choose your filters. Of course, before you open that menu, you have to select the movieclip the menu actions will effect i.e.

colorObj = new Color(selected_movieclip);

Then you select your filter with whatever options you want, be it through setRGB or setTransform, and those effects will be applied to the movieclip.

Because the color object is the menu, deleting it only takes away your ability to change that movieclip's color again unless you make yourself another menu (color object). Deleting the menu will not remove the filters... and in fact any effect to a movieclip is effectively 1 color effect filter as, like I said before, setRGB is just a simple version of setTransform. So everything revolves around what can be achieved through setTransform. Using setTransform on a movieclip again will not add to any previous color effects, but rather, change it to the new setting.

By default each movieclip has a default transform of:

ra = 100 (in a range of -100 to 100)
rb = 0
(in a range of -255 to 255)
ga = 100
(in a range of -100 to 100)
gb = 0
(in a range of -255 to 255)
ba = 100
(in a range of -100 to 100)
bb = 0
(in a range of -255 to 255)
aa = 100
(in a range of -100 to 100)
ab = 0
(in a range of -255 to 255)

These you can actually see in the Flash authoring environment by selecting a clip and in the properties panel selecting
Color: Advanced > Settings...
and there you have your setTransform options.

Using setRGB changes those options to reflect full color of whatever color you've passed. For example, if you made you set an RGB to blue, you would get the following for the transform properties:

ra = 0
rb = 0
ga = 0
gb = 0
ba = 100
bb = 255
aa = 0
ab = 0

Should you ever need to remove a color effect from a movieclip, its just a matter of ... well removing that color as specified from the transform object. This means setting the clip to the original transform settings of:

ra = 100
rb = 0
ga = 100
gb = 0
ba = 100
bb = 0
aa = 100
ab = 0

This can be done either manually using:
 
colorObj.setTransform({ra:100, rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0});

....or by simply saving the getTransform of the movieclip before you do anything to it and reapplying it when you need to reset it. That getTransform however, will be the exact object that's used in the setTransform above. Using getTransform just prevents you from having to write it out. Note that setRGB does not have the ability to remove such colors because of its absolute color applying behavior. Only the setTransform method can restore a movieclip and remove whatever 'filter effects' you might have applied.

Now, in case you were wondering, what those values in the transform object represent. There are 2 properties for each channel: 2 for each Red, Green, Blue and Alpha - each dubbed A (-100 to 100) and B (-255 to 255).

A represents % of current color. As you can see, the default A for every clip is 100 or 100% of current color. This means that for every red, green, blue and alpha part of that clip, 100% of it will be seen and seen 100%. If, for example, you have a red square and you reduce its ra (A of red) down to 0 or 0%, that square will then become black since you just robbed that clip of all of its red. Since it was only red and nothing else, no other colors will be seen so you get black. A purple clip (or magenta rather) in the same situation would turn blue. Magenta is made of red and blue. Reducing a magenta clips ra to 0% would mean all the red is gone and only the blue remains to be seen. The A values also go below 0% down to 100%, but for normal clip color, that has no meaning... not unless there's any B involved.

B represents added color. B lets you give a color to a clip that has no color, and as we all know, color is measured in values of 0 to 255 hence the range set for B. Given a black movieclip, you are able to change its color from black to red by giving that clip a rb of 255. The A in a black clip is already 100%, but since black has no red its not like we can up that anymore to bring it out. To add the red it has to be... added. And that's what B is for. But that's not all. Not only can B add, but it can also take away, hence the -255 portion of its range. Naturally its useless on our black clip so we'll return to the red clip. Given a red clip with a 100% ra, it can be turned black by giving is a rb of -255. Now, since the red clip is already red, if you decided to give it a rb of positive 255, that would only make it more red, which visually, has no effect. Now, however, the ra could be used in its negative range and it could be set to -100% which would knock all the red out of the clip and turn it back to black.

When setRGB is used to set something red, you can see it set all A's and B's to 0 (removing those colors completely) and upped the A and B for red to their max, ensuring absolute red-ness - as is the nature of setRGB. Removing that set color is just a matter of resetting A's to 100 and B's to 0 since then you would have 100% all true normal color and 0 added color.

And let me remind you that all of this happens for and entire clip and ALL of its contents. These colors are like a stain that is coated on to the clip applied so it just seeps in and gets in everything within no matter what it is. So in the case of altering fill and stroke of a movieclip, each one of those elements would need to be completely separate - their own movieclips - if you need to have complete control over each's color.

If you have any questions, feel free to post on the forums.

Senocular
 

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components
flash menus, buttons and components Digicrafts Components
The best flash components ever! Entheos Flash Website Templates
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
flash components Free Website | Make a Website
Streamsolutions Content Delivery Networks Learn how to advertise on kirupa.com