<?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; Actionscript 3</title>
	<atom:link href="http://www.sebastiaanholtrop.com/archives/category/actionscript-3/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>JigLibFlash physics and Away3D experiment</title>
		<link>http://www.sebastiaanholtrop.com/archives/85</link>
		<comments>http://www.sebastiaanholtrop.com/archives/85#comments</comments>
		<pubDate>Thu, 09 Apr 2009 13:26:47 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[JigLibFlash]]></category>
		<category><![CDATA[Physics]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=85</guid>
		<description><![CDATA[I wanted to do some real 3d physics for quite some time, but there just weren&#8217;t really good actionscript 3 physics engines around. There are 2 real options:

WOW Physics engine: This is a particle based engine, which means every vertex has it&#8217;s own physics properties
JigLibFlash Physics engine: This is a Rigid Body based engine. You [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to do some real 3d physics for quite some time, but there just weren&#8217;t really good actionscript 3 physics engines around. There are 2 real options:</p>
<ul>
<li><a title="WOW Physics engine" href="http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/" target="_blank">WOW Physics engine</a>: This is a particle based engine, which means every vertex has it&#8217;s own physics properties</li>
<li><a title="JigLibFlash Physics engine" href="http://www.jiglibflash.com/blog/" target="_blank">JigLibFlash Physics engine</a>: This is a Rigid Body based engine. You work with primitive types like boxes and speres to create a rough shape of you 3d object. These rigid body based engines are faster than particle based engines, because there&#8217;s just one rigid body with physics properties instead of (in case of a simple cube) 8.</li>
</ul>
<p>There&#8217;s quite a lot of examples around built with JigLibFlash and Papervision3D. Because I prefer building my 3D stuff in Away3D, I wanted to create some 3D physics with JigLibFlash and Away3D. Here&#8217;s a simple example of how it works:</p>
<div class="mceTemp">
<dl id="attachment_87" class="wp-caption alignnone" style="width: 510px;">
<dt class="wp-caption-dt"><a title="JiglibFlash and Away3D example" href="http://sebastiaanholtrop.com/samples/jiglibflashexperiment/example/" target="_blank"><img class="size-full wp-image-87" title="jiglibflash-and-away3d-experiment" src="http://www.sebastiaanholtrop.com/wp-content/jiglibflash-and-away3d-experiment.jpg" alt="JigLibFlash and Away3D experiment" width="500" height="300" /></a></dt>
</dl>
</div>
<p>Just use the arrow keys to move the ball around, try to get it to jump the ramp <img src='http://www.sebastiaanholtrop.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . You can <a title="Download source code jiglibFlash Away3D example" href="http://www.sebastiaanholtrop.com/samples/jiglibflashexperiment/JigLibAway3DExperiment.zip" target="_self">download the source code here</a>.</p>
<p>That&#8217;s it for now. it takes a lot of time to figure out how everything works because these physics engines are still buggy and undocumented (grrr). The project members of JigLibFlash did a great job by porting this c++ engine to actionscript, but, for an open source project to be successful they better start documenting the source code (I know it&#8217;s a boring job) instead of creating demo apps with Papervision, which, in my opinion is not the best 3D engine around.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/85/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SebCoverFlow 2.2.1 available</title>
		<link>http://www.sebastiaanholtrop.com/archives/83</link>
		<comments>http://www.sebastiaanholtrop.com/archives/83#comments</comments>
		<pubDate>Thu, 09 Apr 2009 11:43:30 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>
		<category><![CDATA[Adobe Flex 3]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[CoverFlow]]></category>
		<category><![CDATA[Flex 2]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=83</guid>
		<description><![CDATA[Since the release of the source code of my coverflow component there was just one bug that came up again and again. The coverflow couldn&#8217;t load images from a subdomain or another domain. I&#8217;ve fixed that one by adding a LoaderContext to the Image loader. The new sources and samples are available on the SebCoverFlow [...]]]></description>
			<content:encoded><![CDATA[<p>Since the release of the source code of my coverflow component there was just one bug that came up again and again. The coverflow couldn&#8217;t load images from a subdomain or another domain. I&#8217;ve fixed that one by adding a LoaderContext to the Image loader. The new sources and samples are available on the <a title="SebCoverFlow project page" href="http://www.sebastiaanholtrop.com/sebcoverflowprojectpage" target="_self">SebCoverFlow project page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/83/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Mask an Away3D scene in Flex</title>
		<link>http://www.sebastiaanholtrop.com/archives/29</link>
		<comments>http://www.sebastiaanholtrop.com/archives/29#comments</comments>
		<pubDate>Thu, 18 Sep 2008 20:59:48 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>
		<category><![CDATA[Adobe Flex 3]]></category>
		<category><![CDATA[Away3D]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=29</guid>
		<description><![CDATA[An Away3D scene usually takes up the full width and height of the embedded swf file in the browser. In Flash you can easily solve this problem by masking the Away3D view.
The same thing goes for Flex, but Flex has it&#8217;s own measuring and sizing methods. I&#8217;ve come to know that it&#8217;s a great thing [...]]]></description>
			<content:encoded><![CDATA[<p>An Away3D scene usually takes up the full width and height of the embedded swf file in the browser. In Flash you can easily solve this problem by masking the Away3D view.</p>
<p>The same thing goes for Flex, but Flex has it&#8217;s own measuring and sizing methods. I&#8217;ve come to know that it&#8217;s a great thing as regards to performance, maintainability and scalability of your component to adapt to the Flex Framework.</p>
<p>In this case, I&#8217;ve extended a Flex component. The new Component contains an Away3D scene, which wants to take up the full width and height of my Flex Application. To solve this we need to override the updateDisplayList method. This method get&#8217;s called by the Flex Framework every time something in the measuring has changed. Here&#8217;s how it looks in code:</p>

<div class="wp_codebox"><table><tr id="p292"><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
31
32
33
</pre></td><td class="code" id="p29code2"><pre class="actionscript" style="font-family:monospace;">override protected <span style="color: #000000; font-weight: bold;">function</span> updateDisplayList<span style="color: #66cc66;">&#40;</span>unscaledWidth:<span style="color: #0066CC;">Number</span>, unscaledHeight:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #0066CC;">super</span>.<span style="color: #006600;">updateDisplayList</span><span style="color: #66cc66;">&#40;</span>unscaledWidth, unscaledHeight<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Set the clipping of the 3D scene to make sure only the visible elements are rendered,</span>
<span style="color: #808080; font-style: italic;">// this is great improvement for the performance</span>
<span style="color: #000000; font-weight: bold;">var</span> clipping:RectangleClipping = <span style="color: #000000; font-weight: bold;">new</span> RectangleClipping<span style="color: #66cc66;">&#40;</span>-<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>, -<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>, <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>, <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Asign the clipping to the _view3D, in this case a private variable within my class</span>
_view3D.<span style="color: #006600;">clip</span> = clipping;
&nbsp;
<span style="color: #808080; font-style: italic;">// Remove the old mask if there is one</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_mask <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">this</span>.<span style="color: #006600;">removeChild</span><span style="color: #66cc66;">&#40;</span>_mask<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Create a new mask</span>
_mask = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
_mask.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">x</span>;
_mask.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">y</span>;
_mask.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFF0000,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
_mask.<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: #0066CC;">this</span>.<span style="color: #0066CC;">width</span>, <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
_mask.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Add it to the displayList</span>
<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>_mask<span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// And assign the mask to the view3D</span>
_view3D.<span style="color: #006600;">mask</span> = _mask;
&nbsp;
<span style="color: #808080; font-style: italic;">// And center the view3D in the available space</span>
_view3D.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>;
_view3D.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>So as you see above, it&#8217;s quite straighforward. The clipping in the beginning of the method is not necessary for the masking, but since only the masked area is being displayed, there&#8217;s no need to render the invisible parts of the view3D.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/29/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamic Flex CoverFlow Component with dataProvider</title>
		<link>http://www.sebastiaanholtrop.com/archives/27</link>
		<comments>http://www.sebastiaanholtrop.com/archives/27#comments</comments>
		<pubDate>Thu, 11 Sep 2008 19:17:08 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[CoverFlow]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=27</guid>
		<description><![CDATA[There&#8217;s a project page of this component now, check it here, it&#8217;s open source!
As you may have read in a few of my other posts I&#8217;ve hacked a CoverFlow component together, just to see if it could be done. I was glad to see a lot of people liked it, so I decided to turn [...]]]></description>
			<content:encoded><![CDATA[<p><a title="SebCoverflow Project page" href="http://www.sebastiaanholtrop.com/sebcoverflowprojectpage" target="_self">There&#8217;s a project page of this component now, check it here, it&#8217;s open source!</a></p>
<p>As you may have read in a few of my other posts I&#8217;ve hacked a CoverFlow component together, just to see if it could be done. I was glad to see a lot of people liked it, so I decided to turn it into a proper component instead of the &#8220;hacked together&#8221; version I&#8217;ve posted before.</p>
<p><a title="Flex 2 CoverFlow component sample application" href="http://www.sebastiaanholtrop.com/samples/coverFlowcomponent/sampleapp/" target="_blank"><img class="alignnone size-full wp-image-28" title="sebcoverflow" src="http://www.sebastiaanholtrop.com/wp-content/sebcoverflow.jpg" alt="SebCoverFlow component for Flex" width="500" height="238" /></a></p>
<p>A lot of things have changed under the hood, a lot of bugs are fixed and you have to use the component a bit different.</p>
<ul>
<li>The previous version was built as a container, the new version is built more like a dataGrid, so it&#8217;s a component with a dataProvider. The component just renders the data in the dataProvider</li>
<li>It&#8217;s dynamic! It loads the images from the dataProvider. Changes on the dataProvider will be detected through binding</li>
<li>It&#8217;s now compatible with the Flex history manager, I&#8217;ve implemented the IHistoryManagerClient interface</li>
<li>It&#8217;s now compatible with the Flex focus manager, I&#8217;ve implemented the IFocusManagerComponent interface</li>
<li>I&#8217;ve added keyboard control, so the left and right arrow keys change the selected cover</li>
<li>It dispatches events, it lets everyone who&#8217;s listening know that the selectedIndex has changed, that it&#8217;s finished animating, etc</li>
<li>It&#8217;s now properly masked, the 3d scene doesn&#8217;t stretch to the full stage width and height anymore</li>
<li>And some more other small things</li>
</ul>
<p>I&#8217;ve created a new sample project to demonstrate all of the features, <a title="Flex 2 CoverFlow component sample application" href="http://sebastiaanholtrop.com/samples/coverFlowcomponent/sampleapp/" target="_blank">see it in action here</a>. You can see and <a title="Source view of the coverFlow sample project" href="http://sebastiaanholtrop.com/samples/coverFlowcomponent/sampleapp/srcview/index.html">download the source code of the sample project here</a>.</p>
<p>The component free to download and free to use, <a title="Flex 2 CoverFlow component swc" href="http://sebastiaanholtrop.com/samples/coverFlowcomponent/SebCoverFlow.swc">download the swc here</a>. I&#8217;m not publishing the source code of this one for now.</p>
<p>I&#8217;ve created documentation to help you put this component to good use, <a title="Flex 2 CoverFlow component documentation" href="http://sebastiaanholtrop.com/samples/coverFlowcomponent/asdoc/com/sebastiaanholtrop/components/coverflow/SebCoverFlow.html">read it here</a>.</p>
<p>Let me know what you think of it. I&#8217;d also like to see some end results. some projects in which you&#8217;ve used my component.</p>
<p>The next step? Hmm, a <a title="Piclens" href="http://www.cooliris.com/">piclens </a>component perhaps?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/27/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>How to use ASDoc with external libraries</title>
		<link>http://www.sebastiaanholtrop.com/archives/25</link>
		<comments>http://www.sebastiaanholtrop.com/archives/25#comments</comments>
		<pubDate>Thu, 11 Sep 2008 18:57:09 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[ASDoc]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=25</guid>
		<description><![CDATA[Because documenting your code itself isn&#8217;t a really fun job you don&#8217;t want to spend to much time fiddling around with ASDoc as well, so here&#8217;s a short description of how you can generate the documentation simple and easy;
To conveniently call the asdoc.exe command from every folder on your system you have to add the [...]]]></description>
			<content:encoded><![CDATA[<p>Because documenting your code itself isn&#8217;t a really fun job you don&#8217;t want to spend to much time fiddling around with ASDoc as well, so here&#8217;s a short description of how you can generate the documentation simple and easy;</p>
<p>To conveniently call the asdoc.exe command from every folder on your system you have to add the path to the folder asdoc.exe is in to the PATH system variable. Here&#8217;s how: Go to your Control Panel and click System. Go to the Advanced tab and click Environment Variables. In the System Variables list locate the Path variable. If it doesn&#8217;t exist create it. Doubleclick the variable to edit the value and add the location of your Flex bin folder, in my case it is: &#8220;d:\Program Files\Adobe\Flex Builder 2\Flex SDK 2\bin&#8221;. Don&#8217;t replace any of the other values in the variable, the value of the variable is semicolon-separated, so just add the path at the end of the value. Now click OK OK and reboot. After the reboot you should be able to just enter this in the command line: c:\asdoc, and ASDoc should respond with a beautiful error.</p>
<p>I hate typing in a command prompt (I don&#8217;t like typing at all), so I create a batch file to call ASDoc so I can create and recreate my documentation again and again. I place the batch file in the root of my project, so here&#8217;s what my project looks like:</p>
<p><a href="http://www.sebastiaanholtrop.com/wp-content/exampleproject.jpg"><img class="alignleft size-full wp-image-26" title="Flex Library Project" src="http://www.sebastiaanholtrop.com/wp-content/exampleproject.jpg" alt="" width="204" height="193" /></a></p>

<div class="wp_codebox"><table><tr id="p254"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p25code4"><pre class="actionscript" style="font-family:monospace;">asdoc -source-path . -doc-sources . -output asdoc -external-library-path=lib -main-title <span style="color: #ff0000;">&quot;My work API documentation&quot;</span> -window-title <span style="color: #ff0000;">&quot;My work API documentation&quot;</span></pre></td></tr></table></div>

<p>Some explanation about the switches in this command:</p>
<ul>
<li> asdoc: this calls the asdoc command</li>
<li>-source-path: Enter a dot to tell ASDoc that the current folder is the source path</li>
<li>-doc-sources: Enter a dot to tell ASDoc to document all of the sources in the current Folder</li>
<li>-output asdoc: This is the name of the Folder in which the documentation will be generated</li>
<li> -external-library-path: If you use external swc&#8217;s, ASDoc wants to know about them, so enter the Folder in which they are located. In my project above I&#8217;ve used Away3D and Tweener, they are located in the lib folder</li>
<li>-main-title: The title at the top of the document</li>
<li>-window-title: The title the browser window displays</li>
</ul>
<p>Note that the -external-library-path is an undocumented switch, I&#8217;ve spent an hour to get ASDoc to work properly with external libraries. Using -library-path won&#8217;t work, you&#8217;ll replace the Flex Framework by doing that, so ASDoc will say something like &#8220;Hey, what&#8217;s a UIComponent?&#8221;.</p>
<p>Everything should work fine, but with ASDoc you&#8217;re never sure. Just run the batch file from the command line and see what happens.</p>
<p>By the way: don&#8217;t use unsupported tags in your code. The @description tag for instance is not supported, which will result in ASDoc throwing a useless xml parser error.</p>
<p>Good luck, you&#8217;re on your own now&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/25/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Flex CoverFlow Component updated</title>
		<link>http://www.sebastiaanholtrop.com/archives/19</link>
		<comments>http://www.sebastiaanholtrop.com/archives/19#comments</comments>
		<pubDate>Wed, 11 Jun 2008 19:10:30 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[CoverFlow]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=19</guid>
		<description><![CDATA[There&#8217;s a project page of this component now, check it here, it&#8217;s open source!

I&#8217;ve been quite busy working on my CoverFlow component. I&#8217;ve added my reflection class and added the possibility to use cubes instead of planes as a cover. Since I&#8217;ve used a true 3D engine (Away3D) to build this component it&#8217;s become much [...]]]></description>
			<content:encoded><![CDATA[<p><a title="SebCoverflow Project page" href="http://www.sebastiaanholtrop.com/sebcoverflowprojectpage" target="_self">There&#8217;s a project page of this component now, check it here, it&#8217;s open source!<br />
</a></p>
<p>I&#8217;ve been quite busy working on my CoverFlow component. I&#8217;ve added my <a title="Reflection class" href="http://www.sebastiaanholtrop.com/archives/17" target="_blank">reflection class</a> and added the possibility to use cubes instead of planes as a cover. Since I&#8217;ve used a true 3D engine (<a title="Away3D" href="http://away3d.com/" target="_blank">Away3D</a>) to build this component it&#8217;s become much more than just a CoverFlow rip-off. Here are some examples of what it can do:</p>
<p><a href="http://www.sebastiaanholtrop.com/samples/covercube/"><img class="alignnone size-full wp-image-20" title="CoverCube Example" src="http://www.sebastiaanholtrop.com/wp-content/covercubenewexample1.jpg" alt="CoverCube Example" width="500" height="193" /></a></p>
<p><a href="http://www.sebastiaanholtrop.com/samples/covercube/"><img class="alignnone size-full wp-image-21" title="CoverCube example" src="http://www.sebastiaanholtrop.com/wp-content/covercubenewexample2.jpg" alt="CoverCube example" width="500" height="193" /></a></p>
<p><a title="CoverCube" href="http://www.sebastiaanholtrop.com/samples/covercube/">Click here to see the CoverCube in action</a>. Try the presets and drag the sliders to explore the possibilities of this component.<br />
<a title="Covercube source code" href="http://www.sebastiaanholtrop.com/samples/covercube/srcview/index.html">Click here to view the source code.</a></p>
<p>Here&#8217;s a few examples of the component using just planes:</p>
<p><a href="http://www.sebastiaanholtrop.com/samples/coverflowv2/"><img class="alignnone size-full wp-image-22" title="CoverFlow example" src="http://www.sebastiaanholtrop.com/wp-content/coverflownewexample.jpg" alt="CoverFlow example" width="500" height="193" /></a></p>
<p><a href="http://www.sebastiaanholtrop.com/samples/coverflowv2/"><img class="alignnone size-full wp-image-23" title="CoverFlow example" src="http://www.sebastiaanholtrop.com/wp-content/coverflownewexample2.jpg" alt="CoverFlow example" width="500" height="193" /></a></p>
<p><a title="CoverFlow V2" href="http://www.sebastiaanholtrop.com/samples/coverflowv2/">Click here to see the CoverFlowV2 in action</a>. Try the presets and drag the sliders to explore the possibilities of this component.<br />
<a title="CoverFlowV2 source code" href="http://www.sebastiaanholtrop.com/samples/coverflowv2/srcview/index.html">Click here to view the source code.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/19/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<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="p177"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p17code7"><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="p178"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p17code8"><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>
		<item>
		<title>BitmapData and Matrix weirdness</title>
		<link>http://www.sebastiaanholtrop.com/archives/16</link>
		<comments>http://www.sebastiaanholtrop.com/archives/16#comments</comments>
		<pubDate>Mon, 26 May 2008 21:29:33 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=16</guid>
		<description><![CDATA[Yet another weird actionscript problem that&#8217;s been bothering me for some time. I&#8217;m trying to make a BitmapData snapshot of a Flex Component and then transform it with a Matrix. Quite simple you would say, this is how you would do it:

1
2
3
4
5
var flippedBmd:BitmapData = new BitmapData&#40;myUIComponent.width, myUIComponent.height, true, 0xFFCC00&#41;;
var flipMatrix:Matrix = new Matrix&#40;&#41;;
flipMatrix.scale&#40;-1, 1&#41;;
flipMatrix.translate&#40;myUIComponent.width, 0&#41;;
flippedBmd.draw&#40;myUIComponent, [...]]]></description>
			<content:encoded><![CDATA[<p>Yet another weird actionscript problem that&#8217;s been bothering me for some time. I&#8217;m trying to make a BitmapData snapshot of a Flex Component and then transform it with a Matrix. Quite simple you would say, this is how you would do it:</p>

<div class="wp_codebox"><table><tr id="p1610"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p16code10"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> flippedBmd:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>myUIComponent.<span style="color: #0066CC;">width</span>, myUIComponent.<span style="color: #0066CC;">height</span>, <span style="color: #000000; font-weight: bold;">true</span>, 0xFFCC00<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> flipMatrix:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
flipMatrix.<span style="color: #006600;">scale</span><span style="color: #66cc66;">&#40;</span>-<span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
flipMatrix.<span style="color: #006600;">translate</span><span style="color: #66cc66;">&#40;</span>myUIComponent.<span style="color: #0066CC;">width</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
flippedBmd.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>myUIComponent, flipMatrix<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Where myUiComponent is any Flex Component instance.</p>
<p>This all works well, except for the text in the Component, all &#8216;dynamic&#8217; texts won&#8217;t show in the BitmapData, whil everything works well if I comment out the flipmatrix.scale and flipmatrix.translate lines.</p>
<p>You can see this weird behavior in action <a title="Weird bitmapdata and matrix behavior in action" href="http://www.sebastiaanholtrop.com/samples/bitmapdataandtext/" target="_blank">here</a>. Try it by clicking the &#8216;Flip&#8217; button.</p>
<p>The first one who gives me a BitmapData-only solution to this problem deserves a free beer!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/16/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iTunes CoverFlow Flex 2 component with Away3D</title>
		<link>http://www.sebastiaanholtrop.com/archives/5</link>
		<comments>http://www.sebastiaanholtrop.com/archives/5#comments</comments>
		<pubDate>Sun, 20 Apr 2008 20:52:11 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[CoverFlow]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=5</guid>
		<description><![CDATA[There&#8217;s a project page of this component now, check it here, it&#8217;s open source!
I&#8217;ve been fiddling around with 3d engines in Flash for about a year now, but never used it in Flex before, so I decided to try to build an iTunes coverflow component in Flex. This was what i came up with:

Not really [...]]]></description>
			<content:encoded><![CDATA[<p><a title="SebCoverflow Project page" href="http://www.sebastiaanholtrop.com/sebcoverflowprojectpage" target="_self">There&#8217;s a project page of this component now, check it here, it&#8217;s open source!</a></p>
<p>I&#8217;ve been fiddling around with 3d engines in Flash for about a year now, but never used it in Flex before, so I decided to try to build an iTunes coverflow component in Flex. This was what i came up with:</p>
<p><a href="http://www.sebastiaanholtrop.com/samples/coverflow/" target="_blank"><img class="alignnone size-full wp-image-6" title="coverflowfront" src="http://www.sebastiaanholtrop.com/wp-content/coverflowfront.jpg" alt="iTunes Coverflow with Flex and Away3D" width="500" height="193" /></a></p>
<p>Not really anything special, but since i&#8217;ve used a real 3D engine, i can do more stuff with it, like this:</p>
<p><a href="http://www.sebastiaanholtrop.com/samples/coverflow/" target="_blank"><img class="alignnone size-full wp-image-7" title="coverflowside" src="http://www.sebastiaanholtrop.com/wp-content/coverflowside.jpg" alt="" width="500" height="323" /></a></p>
<p>and this:</p>
<p><a href="http://www.sebastiaanholtrop.com/samples/coverflow/" target="_blank"><img class="alignnone size-full wp-image-8" title="coverflowtop" src="http://www.sebastiaanholtrop.com/wp-content/coverflowtop.jpg" alt="" width="500" height="281" /></a></p>
<p>There&#8217;s still a lot of work to do before it&#8217;s really useful, but i&#8217;m pretty content with the results so far.</p>
<p>I don&#8217;t know if I&#8217;ll ever finish this component. To me it was just a case study in which I wanted to explore the possibilities of the combination of a 3D engine and Flex.</p>
<ul>
<li><a href="http://www.sebastiaanholtrop.com/samples/coverflow/">View the example</a></li>
<li><a href="http://www.sebastiaanholtrop.com/samples/coverflow/srcview/index.html">Download the sourcode</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/5/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Adding a Sprite as a child to a Flex Container</title>
		<link>http://www.sebastiaanholtrop.com/archives/3</link>
		<comments>http://www.sebastiaanholtrop.com/archives/3#comments</comments>
		<pubDate>Tue, 08 Apr 2008 07:46:10 +0000</pubDate>
		<dc:creator>Sebastiaan</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex 2]]></category>

		<guid isPermaLink="false">http://www.sebastiaanholtrop.com/?p=3</guid>
		<description><![CDATA[This is a problem i stumbled upon while trying to add a Sprite or MovieClip (or any DisplayObject) with actionscript to my DisplayList in Flex. I wanted to add a View3D (which is an extended Sprite) to my DisplayList in Flex. This just didn&#8217;t work because the Container Class overrides the addChild method:

1
2
var canvas:Canvas = [...]]]></description>
			<content:encoded><![CDATA[<p>This is a problem i stumbled upon while trying to add a Sprite or MovieClip (or any DisplayObject) with actionscript to my DisplayList in Flex. I wanted to add a View3D (which is an extended Sprite) to my DisplayList in Flex. This just didn&#8217;t work because the Container Class overrides the addChild method:</p>

<div class="wp_codebox"><table><tr id="p315"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p3code15"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> canvas:Canvas = <span style="color: #000000; font-weight: bold;">new</span> Canvas<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
canvas.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span><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: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>According to the documentation i can add any type of DisplayObject as a child to any type of Container, but when you try to do that you&#8217;ll get this:</p>

<div class="wp_codebox"><table><tr id="p316"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3code16"><pre class="actionscript" style="font-family:monospace;">cannot convert flash.<span style="color: #006600;">display</span>::Sprite<span style="color: #66cc66;">@</span>54abdd1 to mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">IUIComponent</span></pre></td></tr></table></div>

<p>This is because Canvas, or more specific, Container tries to cast our newly created Sprite to a UIComponent, which is an Object lower in the Flex inheritance chain and casting to a more specific type is not allowed. This is one of the basic principles of Object Oriented Programming; you can&#8217;t cast any object to another object of a more specific type because you would add functionality to it by doing that.</p>
<p>I could just add my Sprite to the rawChildren property of my container like this:</p>

<div class="wp_codebox"><table><tr id="p317"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p3code17"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> sprite:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
canvas.<span style="color: #006600;">rawChildren</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>sprite<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>But that&#8217;s not a really nice solution because the sprite wouldn&#8217;t behave like a Flex component and I would get my Sprite mixed up with all of the skinning Sprites and MovieClips of the container.</p>
<p>But I&#8217;m wandering off now, here&#8217;s the solution to our little Flex and Sprites and addChild problem:</p>

<div class="wp_codebox"><table><tr id="p318"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p3code18"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> canvas:Canvas = <span style="color: #000000; font-weight: bold;">new</span> Canvas<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> uiComponent:UIComponent = <span style="color: #000000; font-weight: bold;">new</span> UIComponent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
canvas.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>uiComponent<span style="color: #66cc66;">&#41;</span>;
uiComponent.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span><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: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Just use a UIComponent as a container for the Sprite. For as far as i know UIComponent is the only component that can actually add a Non-Flex-Component as a child.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastiaanholtrop.com/archives/3/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
