<?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>Sebastiaan Holtrop &#187; Adobe Flash</title>
	<atom:link href="http://www.sebastiaanholtrop.com/archives/category/adobe-flash/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sebastiaanholtrop.com</link>
	<description>Creating stuff that works...</description>
	<lastBuildDate>Mon, 08 Feb 2010 11:39:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex Reflections Component and Actionscript Class</title>
		<link>http://www.sebastiaanholtrop.com/archives/17</link>
		<comments>http://www.sebastiaanholtrop.com/archives/17#comments</comments>
		<pubDate>Wed, 28 May 2008 21:46:02 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>
		<category><![CDATA[Away3D]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=17</guid>
		<description><![CDATA[There are a lot of Reflection classes around, but I always enjoy writing my own. I had a special purpose in mind with writing this one; I wanted to create a reflection of a displayObject as a BitmapData, so I could use it as a Material in Away3D or any other actionscript 3D API. One [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of Reflection classes around, but I always enjoy writing my own. I had a special purpose in mind with writing this one; I wanted to create a reflection of a displayObject as a BitmapData, so I could use it as a Material in Away3D or any other actionscript 3D API. One thing led to another, and before I knew I was writing a Reflection Flex component as well.</p>
<p>So the idea is that there are two flavors to this Reflection classes:</p>
<ul>
<li>The Actionscript-only way to create a Reflection</li>
<li>The MXML-only way to create a Reflection</li>
</ul>
<p>I also wanted to be able to create a reflection of a video or any other moving object. Check the example to see it in action.</p>
<p><a href="http://www.sebastiaanholtrop.com/samples/reflections/" target="_blank"><img class="alignnone size-medium wp-image-18" title="reflectionexample" src="http://www.sebastiaanholtrop.com/wp-content/reflectionexample-300x291.jpg" alt="An image with reflection using Actionscript and or Flex" width="300" height="291" /></a></p>
<h2>The Actionscript-only way to create a Reflection</h2>
<p>I&#8217;ve created this one so you can create reflections in Flash or in any Actionscript project. I&#8217;m going to use this to create reflection BitmapData&#8217;s to use in Away3D. Here&#8217;s how you use it:</p>

<div class="wp_codebox"><table><tr id="p173"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p17code3"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> reflection:Reflect = <span style="color: #000000; font-weight: bold;">new</span> Reflect<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #006600;">image1</span> as Sprite, <span style="color: #cc66cc;">0.4</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #000000; font-weight: bold;">true</span>, Reflect.<span style="color: #006600;">BOTTOM</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>The constructor arguments are:</p>
<ul>
<li>The sprite to reflect</li>
<li>the alpha value</li>
<li>the ratio value</li>
<li>a boolean to tell if it should be added as a child to the target sprite</li>
<li>the direction of the reflection</li>
<li>the updateTime, this one is set to 0, so it doesn&#8217;t periodically update the reflection</li>
</ul>
<p>See the example <a title="Reflections sample" href="http://www.sebastiaanholtrop.com/samples/reflections/" target="_blank">here<br />
</a>See the sourcecode <a title="Reflections sample sourcecode" href="http://www.sebastiaanholtrop.com/samples/reflections/srcview/index.html" target="_blank">here</a></p>
<h2>The MXML-only way to create a Reflection</h2>
<p>The component version uses exactly the same arguments as the Actionscript class. All properties (except for the updateTime) are bindable, so you can alter the alpha, ratio, etc at runtime.</p>

<div class="wp_codebox"><table><tr id="p174"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p17code4"><pre class="xml" style="font-family:monospace;">&nbsp;</pre></td></tr></table></div>

<p>See the example <a title="Reflections sample" href="http://www.sebastiaanholtrop.com/samples/reflections/" target="_blank">here<br />
</a>See the sourcecode <a title="Reflections sample sourcecode" href="http://www.sebastiaanholtrop.com/samples/reflections/srcview/index.html" target="_blank">here</a></p>
<p>There&#8217;s one problem with reflecting dynamic textfields. I&#8217;m using a Matrix to create the Flipped BitmapData. Unfortunately the scale and translate methods of the Matrix mess up the rendering of dynamic textfields, but hey, who would want to reflect a boring textfield or dateChooser <img src='http://www.sebastiaanholtrop.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
I&#8217;ve written a post about this problem, you can read it <a title="BitmapData and Matrix weirdness" href="http://www.sebastiaanholtrop.com/archives/16" target="_self">here</a>. I know the solution to this problem; Use a Bitmap and set the scaleY property, but this will only flip the Bitmap, the BitmapData is still not flipped, and as I mentioned before, this was all to do about the Flipped and reflected BitmapData.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/17/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>
