<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flash and ActionScript tutorials - flashadvanced &#187; ColorPicker</title>
	<atom:link href="http://flashadvanced.com/tag/colorpicker/feed/" rel="self" type="application/rss+xml" />
	<link>http://flashadvanced.com</link>
	<description>Become an advanced flash developer</description>
	<lastBuildDate>Mon, 11 Jan 2010 22:14:13 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gradient background color changer</title>
		<link>http://flashadvanced.com/actionscript-3-basics/gradient-background-color-changer/</link>
		<comments>http://flashadvanced.com/actionscript-3-basics/gradient-background-color-changer/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 18:07:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[ColorPicker]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[gradient background]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=420</guid>
		<description><![CDATA[


In this tutorial you will learn how to use the AS3 Color Picker component to change the color of your gradient background. I will show you the technique of creating a nice gradient background

Note: In order to complete this tutorial you need to download TweenMax library. Do it by clicking here. Unzip the downloaded file [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=420"><br />
<img src="http://flashadvanced.com/wp-content/upload/cpicker/cpicker.jpg" /><br />
</a></p>
<p>In this tutorial you will learn how to use the <strong>AS3 Color Picker</strong> component to change the color of your gradient background. I will show you the technique of creating a <strong>nice gradient background</strong></p>
<p><span id="more-420"></span></p>
<h4>Note: In order to complete this tutorial you need to download TweenMax library. Do it by clicking <a href="http://blog.greensock.com/tweenmaxas3/">here</a>. Unzip the downloaded file in the same directory as the Flash files!</h4>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;ColorPicker.fla&#8221;. Set the size to 450 x 200 pixels.</p>
<p><span style="color: #ff0000;">2.</span> Take the rectangle tool, disable the stroke color, for fill color choose #999999 and then draw a rectangle with the same size as the document size. Convert the rectangle to movie clip and give it an instance name &#8220;bg&#8221;. Align the movie clip so it covers the stage.</p>
<p><span style="color: #ff0000;">3.</span> Create a new layer called &#8220;color picker&#8221;. Go to <strong>Window -> Components</strong> and drag a <strong>ColorPicker</strong> component to the stage. Give it instance name &#8220;cp&#8221;.</p>
<p><span style="color: #ff0000;">3.</span> Create a new layer called &#8220;gradient&#8221; and take the rectangle tool again. Disable the stroke color and draw a rectangle with size 450px by 200px. Position it so it covers the stage. Select the rectangle and go to the Color Panel by clicking Window -> Color. Under &#8220;type&#8221; choose &#8220;Radial&#8221;. For left color choose #E1E1E1 and set its alpha value to 25%. For right color choose #555555 and set its alpha value to 35%:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/cpicker/gradient.jpg" /></p>
<p>This is how you make <strong>gradient backgrounds</strong> in flash.</p>
<p><span style="color: #ff0000;">4.</span> Create a new layer called &#8220;actions&#8221; and open the Actions Panel.</p>
<pre><code>
//importing classes
import fl.events.ColorPickerEvent;
import flash.geom.ColorTransform;
import gs.*;

//getting the color info
var colorInfo:ColorTransform = bg.transform.colorTransform;

//adding an event listener for color change
cp.addEventListener (ColorPickerEvent.CHANGE, colorChanged);

function colorChanged (e:ColorPickerEvent):void {

	//setting the color of the ColorTransform object
	colorInfo.color = cp.selectedColor;

	//applying the color change animation with TweenMax
	TweenMax.to(bg, 1, {tint:cp.selectedColor});
}
</code></pre>
<p>This is the easiest way to create a nice gradient background color changer using Color Picker component and TweenMax. </p>
<h4>Here is the final result:</h4>
<p><object width="450" height="200"><param name="movie" value="http://flashadvanced.com/wp-content/upload/cpicker/ColorPicker.swf"><embed src="http://flashadvanced.com/wp-content/upload/cpicker/ColorPicker.swf" width="450" height="200"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/cpicker/ColorPicker.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/actionscript-3-basics/gradient-background-color-changer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
