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

Flash / AS



ASP.net / PHP






  Design & Effects
  Audio & Video
  User Interface





Easy Random Color
         by ilyas usal

Some of you may have read Kirupa's tutorial about random colors, and you may have found that it was very very complicated. Well don't worry, there is a much easier method that I will explain here.

First you have to know that colors in Flash are represented by hexadecimal values, that is to say numbers that look like:

myColor = 0xFF0055;

The 0x means it's hexadecimal, followed by 6 digits going from 0 to 15, except they are noted A=10, B=11, C=12, D=13, E=14 and F=15. The 2 first digits code the red (FF is totally red, 00 is no red), the 2 middle digits code the green and the last 2 code the blue.

Now to get a random color, all we have to do is take a random hexadecimal value, between 0x000000 and 0xFFFFFF, and then round it. Then we can do whatever we want with it (check the setRGB() tutorial for more information about that function). Here I tint an object called square:

myColor = Math.round( Math.random()*0xFFFFFF );
myColoredObject = new Color (_root.square);



Hope this tutorial helped. If you have any questions, please post them on the forums at //www.kirupa.com/forum/


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