<?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, Flex and ActionScript tutorials - flashadvanced &#187; colorTransform</title>
	<atom:link href="http://flashadvanced.com/tag/colortransform/feed/" rel="self" type="application/rss+xml" />
	<link>http://flashadvanced.com</link>
	<description>Become an advanced actionscript developer</description>
	<lastBuildDate>Sun, 30 Jan 2011 21:10:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Random color transform with AS3</title>
		<link>http://flashadvanced.com/random-color-transform-with-as3/</link>
		<comments>http://flashadvanced.com/random-color-transform-with-as3/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 01:26:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[colorTransform]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[random color]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=320</guid>
		<description><![CDATA[In this quick tutorial I will show you how to change the color of a Movie Clip using the Color Transform class and Math.random. 1. Open a new Flash CS3 document with size 400 x 100. 2. Create your logo on the stage. I made the Flashadvanced logo. Give it an instance name &#8220;logo_mc&#8221;. 3. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=320"><br />
<img src="http://flashadvanced.com/wp-content/upload/cTransform/cTransform.jpg" /><br />
</a></p>
<p>In this <strong>quick</strong> tutorial I will show you how to change the color of a Movie Clip using the <strong>Color Transform</strong> class and <strong>Math.random</strong>.</p>
<p><span id="more-320"></span></p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash CS3 document with size 400 x 100.<br />
<span style="color: #ff0000;">2.</span> Create your logo on the stage. I made the <strong>Flashadvanced</strong> logo. Give it an instance name &#8220;logo_mc&#8221;.<br />
<span style="color: #ff0000;">3.</span> Create a new layer called &#8220;button&#8221;. Take the rectangle tool and draw a rectangle for your button. Select it and convert it to Button symbol with instance name &#8220;change_btn&#8221;.<br />
<span style="color: #ff0000;">4.</span> Now we move to ActionScript:</p>
<pre><code>
//we import transform classes
import flash.geom.ColorTransform;
import flash.geom.Transform;

//variable for the color value
var col:uint;
//creating a color transform object
var cTransform:ColorTransform = transform.colorTransform;

//when clicking the button we change the color
change_btn.addEventListener(MouseEvent.CLICK, changeColor);

function changeColor(e:MouseEvent):void{
	//random color value
	col = Math.random()*0xffffff;
	cTransform.color = col;
	logo_mc.transform.colorTransform = cTransform;
}
</code></pre>
<p>That was quick and easy, right?</p>
<h4>This is the final result</h4>
<p><object width="400" height="100"><param name="movie" value="http://flashadvanced.com/wp-content/upload/cTransform/randomCol.swf"><embed src="http://flashadvanced.com/wp-content/upload/cTransform/randomCol.swf" width="400" height="100"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/cTransform/randomCol.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/random-color-transform-with-as3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

