<?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>zedia flash blog &#187; interpolateColor</title>
	<atom:link href="http://www.zedia.net/tag/interpolatecolor/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zedia.net</link>
	<description>Flash, ActionScript, SEO and everything in between</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:58:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>My new friend setTint</title>
		<link>http://www.zedia.net/2007/my-new-friend-settint/</link>
		<comments>http://www.zedia.net/2007/my-new-friend-settint/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 00:09:52 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[fl.motion.color]]></category>
		<category><![CDATA[interpolateColor]]></category>
		<category><![CDATA[setTint]]></category>

		<guid isPermaLink="false">http://www.zedia.net/2007/my-new-friend-settint/</guid>
		<description><![CDATA[I played around today with a method named setTint from the fl.motion.Color class. At first I was a bit confused because this method doesn&#8217;t return anything contrarily to the interpolateColor method which returns a color in hexadecimal. You have to use setTint in this way: 1 2 3 4 5 import fl.motion.Color; import flash.geom.ColorTransform; var [...]]]></description>
			<content:encoded><![CDATA[<p>I played around today with a method named setTint from the fl.motion.Color class. At first I was a bit confused because this method doesn&#8217;t return anything contrarily to the interpolateColor method which returns a color in hexadecimal. You have to use setTint in this way:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">motion</span>.<span style="color: #0066CC;">Color</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">ColorTransform</span>;
<span style="color: #000000; font-weight: bold;">var</span> ct:<span style="color: #0066CC;">Color</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Color</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
ct.<span style="color: #006600;">setTint</span><span style="color: #66cc66;">&#40;</span>0xFF0000, <span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#41;</span>;
mc.<span style="color: #006600;">transform</span>.<span style="color: #006600;">colorTransform</span> = ct;</pre></td></tr></table></div>

<p>With mc being the displayObject you want it applied on. setTint can be pretty useful for setting a tint on a bitmap and it can also be used with tweens in the same way I used the interpolateColor in a previous post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2007/my-new-friend-settint/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Tweening colors using Color.interpolateColor</title>
		<link>http://www.zedia.net/2007/tweening-colors-using-colorinterpolatecolor/</link>
		<comments>http://www.zedia.net/2007/tweening-colors-using-colorinterpolatecolor/#comments</comments>
		<pubDate>Mon, 22 Oct 2007 01:43:17 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[fl.motion.color]]></category>
		<category><![CDATA[interpolateColor]]></category>

		<guid isPermaLink="false">http://www.zedia.net/2007/tweening-colors-using-colorinterpolatecolor/</guid>
		<description><![CDATA[I have been looking for a long time for a way to tween colors in Flash and while browsing around I came across the Color class and the interpolateColor method. I then wanted to see how it worked. It is not that obvious so here is the code: 1 2 3 4 5 6 7 [...]]]></description>
			<content:encoded><![CDATA[<p>I have been looking for a long time for a way to tween colors in Flash and while browsing around I came across the Color class and the interpolateColor method. I then wanted to see how it worked. It is not that obvious so here is the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">Tween</span>;
<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">TweenEvent</span>;
<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">easing</span>.<span style="color: #66cc66;">*</span>;
<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">motion</span>.<span style="color: #0066CC;">Color</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #66cc66;">*</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">ColorTransform</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> simpleSprite:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
simpleSprite.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">100</span>;
simpleSprite.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">100</span>;
simpleSprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
simpleSprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xff0000<span style="color: #66cc66;">&#41;</span>;
simpleSprite.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">200</span>,<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span>simpleSprite<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Get access to the ColorTransform instance associated with our sprite.</span>
<span style="color: #000000; font-weight: bold;">var</span> colorInfo:ColorTransform = simpleSprite.<span style="color: #006600;">transform</span>.<span style="color: #006600;">colorTransform</span>;
<span style="color: #808080; font-style: italic;">// This function is called when the stage is clicked.</span>
<span style="color: #000000; font-weight: bold;">function</span> makeBlue<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> tempMovie:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> alphaOver:Tween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span>tempMovie, <span style="color: #ff0000;">&quot;alpha&quot;</span>, Strong.<span style="color: #006600;">easeOut</span>,<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">8</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
  alphaOver.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TweenEvent.<span style="color: #006600;">MOTION_CHANGE</span>, tweenToBlue<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> tweenToBlue<span style="color: #66cc66;">&#40;</span>event:TweenEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// apply the change to the display object</span>
  colorInfo.<span style="color: #0066CC;">color</span> = <span style="color: #0066CC;">Color</span>.<span style="color: #006600;">interpolateColor</span><span style="color: #66cc66;">&#40;</span>0xff0000, 0x003399, event.<span style="color: #0066CC;">position</span><span style="color: #66cc66;">&#41;</span>;
  simpleSprite.<span style="color: #006600;">transform</span>.<span style="color: #006600;">colorTransform</span> = colorInfo;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, makeBlue<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>The first block of code is to import all that is needed to do our Tweening. The two classes that are of importance are the fl.motion.Color and flash.geom.ColorTransform.</p>
<p>In the second block of code, I create the Sprite that I will do the tweening on and draw a red rectangle in it using the graphics.drawRect method.</p>
<p>After that, it&#8217;s the listening function to the mouse event CLICK on the stage. This function create a new Sprite that will never be displayed. Its sole purpose will be to use its properties to do our Tween. Then we create our Tween as we would normally and we add a listener for the MOTION_CHANGE event.</p>
<p>All the good stuff happens in the next function; tweenToBlue. It is here that we use the static method interpolateColor of the Color class. We use the event&#8217;s position to give us the place where the Tween is at. That is why in our Tween as to have the start parameter as to be 0 and the end parameter as to be 1. We than apply to colorTransform to our Sprite.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2007/tweening-colors-using-colorinterpolatecolor/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

