• Home
  • Free Tutorials
  • Free Video Tutorials

Adobe Photoshop
Autodesk 3ds Max
CSS
Flash
Help Center Live
iPhone
Joomla
Make Money Online!
Mambo
mIRC
Outlook Express
SEO / SEM
Simple Machine Forum
Target Explorer

Color Chooser

Category : Flash Views : 23517
Version : 8 Rating : 
2.9/5 (43 votes)
  • Currently 2.86/5
  • 1
  • 2
  • 3
  • 4
  • 5
Type : Text Source File: color-chooser.zip
Result: See the result


Previous | 1 | 2 | Next

You can use this in customizable applications; the user clicks on the color of his choice and the sample changes to that color and the text show the hexadecimal code.
Free Flash Tutorials, Actionscript, Color Chooser

First get an image like this one:
Free Flash Tutorials, Actionscript, Color Chooser

The code works for any image, but this one is fine.

Import the image to your library and set a linkage using the identifier "colors".

Now create a new Movie Clip and draw a small square of any color you want, then drag it to the stage and give the instance name "userColor".

On the stage draw a dynamic textbox with the instance name "colorTxt", place it next to the "userColor" Movie Clip.
Free Flash Tutorials, Actionscript, Color Chooser

Paste the actions for the first frame:
//import bitmap objects and functions import flash.display.BitmapData; //create a bitmap object with the image in our library colorBitmap = BitmapData.loadBitmap("colors"); //Movie Clip to hold the image _root.createEmptyMovieClip("image", 5); //attach the bitmap to the new Movie Clip image.attachBitmap(colorBitmap, 5); //don稚 use hand cursor over the image to //be easier to choose a color image.useHandCursor = false; //color object linked with the userColor Movie Clip, if we //change mcColor we also change the color of the Movie Clip mcColor = new Color(userColor); _root.onEnterFrame = function() { //if this function return 0 the mouse is not inside the image if (colorBitmap.getPixel(_xmouse, _ymouse) != 0) { //explained below mcColor.setRGB("0x" + colorBitmap.getPixel(_xmouse, _ymouse).toString(16)); } } mcColor.setRGB("0x" + colorBitmap.getPixel(_xmouse, _ymouse).toString(16));

This code sets the color of the Movie Clip to the hexadecimal value of the pixel in the coordinates of the mouse.


More cool tech articles from other blogs.

Place your ad here
Loading...


Previous | 1 | 2 | Next
How to Video Tutorials on software by Helpvids.com

Sponsors





Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.