Imajine Blog Imajine Articles
Contact Me

The Color object in flash

The color object in flash allows us to set RGB color value to movie clip symbols. They also help us retrieve the value once set

First and foremost, we will have to create a color object before calling its methods.

public Color(target:Object)

The above code creates a color object for the movie clip specified by the 'target_mc' parameter. We can then use methods of that color object to change color of entire target movie clip.

Color class methods -

  • getRGB()
  • getTransform()
  • setRGB()
  • setTransform()

setRGB() sets an hexadecimal color value to the entire movie clip.

setTransform() helps us set detailed color values to the movie clip. Here you get to decide the amount of red, green, blue and alpha value you would like to add to your movie clip. As setTransform goes into details, it is a little complicated to use.

Let me list out the variables used in set Transform –

  • 'ra' is the percentage for the red component (-100 to 100).
  • 'rb' is the offset for the red component (-255 to 255).
  • 'ga' is the percentage for the green component (-100 to 100).
  • 'gb' is the offset for the green component (-255 to 255).
  • 'ba' is the percentage for the blue component (-100 to 100).
  • 'bb' is the offset for the blue component (-255 to 255).
  • 'aa' is the percentage for alpha (-100 to 100).
  • 'ab' is the offset for alpha (-255 to 255).

Below is a simple example on how we can set RGB to movie clip

 
Please follow steps below to create flash color pallete as shown above.
  • Draw a vector rectangular diagram which fits the entire screen on your canvas
  • Convert the same to a movie clip symbol and give an instance name as 'color1_mc'
  • Add another layer above this
  • Drag the above movie clip symbol from your library to your canvas and reduce their sizes to 25 x 25 px. Place the same in the bottom.
  • Give any tint color you like
  • Similarly, repeat the above 2 steps and create a pallete of colors as shown in the above flash 'color pallete' example
  • Create another layer and name it 'actions'
  • Now lets begin with the actionscript coding
  • Select 'Frame1' of actionscript layer, and in your actions window paste below script

    var my_color:Color = new Color(color_mc);


    The above code is to create a color object.
    As you can recollect, this is the first step which needs to be done.
  • Select each color option small square movie clip and in their rescetive action window, Paste the below code and change hexadecimal color value to the ones you want.
    eg - 0 x the hexadecimal color code

    on(release)
    {
    _root.my_color.setRGB(0x3a505f);
    }

  • Your color pallete is ready. Press ctrl+Enter to view the same. Click on the color options and you can see your background color change.

Click here to download the source file.

Tags: Color Object in Flash, Color using actionscript, RGB() actionscripting

Download Free Photo Gallery

Download Free Photo Gallery

You can download Imajine's Scrapbook Photo Gallery absolutely free of cost and to customize , you need no knowledge of Adobe Flash.  Click here to view Scrapbook Photo Gallery / download

Tutorials
Flash Tutorials
Horizontal 3D Carousel
MP3 Player
Scrapbook Photo Gallery
Text Enhancement
Color object
Glow effect using actionscript
Drawing with actionscript
Blur Effect
Load external .mp3 file
Preload external .mp3 file
Sound Controller
Set volume of externally .mp3 file
View MP3 song details
Actionscript blur effect
Actionscript fade in / out effect
Fireworks Tutorials
Custom Stroke
Typography / Ink blot effect
Photograph focus effect
Rainbow Pattern
Inset Text Effect
Fuzzy Light Blending Mode
Little bulb effect
Old paper effect
'Post it' effect
Hand drawn designs
Black/White and Sepia tone
Water color painting effect
Vintage effect on vector graphics
Solid color, black/white
Photoshop Tutorials
Photo editing
Purple Haze

Portfolio

Logos
Website design
CMS Customization
Flash
Web development
Print


Download free textures and patterns and use it for your personal use.

Click here to download Textures and Patterns.

Download free birthday cards

Free Birthday Cards
Click here to view Imajine's free downloadable birthday cards for personal and corporate use. Imajine's birthday cards are in jpeg format so it is faster to download and send in your wishes to your friends and family.
Bookmark and Share Tell a Friend jayanthi.varma@imajine.in  |  © 2008 Imajine