<?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>Caffeine Induced Ramblings - Jasper Potts's Blog &#187; JavaFXApplications</title>
	<atom:link href="http://www.jasperpotts.com/blog/category/javafxapplications/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasperpotts.com/blog</link>
	<description>Jasper Potts's Blog on Java and Life</description>
	<lastBuildDate>Tue, 24 Nov 2009 17:58:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Devoxx/Parleys.com Intro Video in JavaFX</title>
		<link>http://www.jasperpotts.com/blog/2009/01/devoxxparleyscom-intro-video/</link>
		<comments>http://www.jasperpotts.com/blog/2009/01/devoxxparleyscom-intro-video/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 16:18:44 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JavaFXApplications]]></category>
		<category><![CDATA[Devoxx]]></category>
		<category><![CDATA[Devoxx 2008]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Parleys.com]]></category>

		<guid isPermaLink="false">http://www.jasperpotts.com/blog/?p=158</guid>
		<description><![CDATA[Following on from the success of the JavaFX Devoxx animations Stephan Janssen asked if I could do a similar video to replace last years intro video that is played before the start of each of the recorded sessions. I decided this was another chance to see how JavaFX copes with animation. This time I needed a 10-15second clip [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from the success of the <a href="http://www.jasperpotts.com/blog/2009/01/devoxx-themed-swish-demo/">JavaFX Devoxx animations</a> Stephan Janssen asked if I could do a similar video to replace last years intro video that is played before the start of each of the recorded sessions. I decided this was another chance to see how JavaFX copes with animation. This time I needed a 10-15second clip of PAL video 768&#215;576 25fps. In this blog I will explain how I created this animation and take you though recreating it step by step. I started out creating the graphics in Photoshop based on the ones I had from the Devoxx theme for Swish with all the parts that I am going to need to animate as separate layers. All the layers I want to access from JavaFX are named with the &#8220;jfx:&#8221; prefix and simple camel case names so they will be exposed to JavaFX code and come though as neat variable names.</p>
<div id="attachment_159" class="wp-caption alignnone" style="width: 528px"><img class="size-full wp-image-159" title="complete" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/complete.png" alt="Complete Graphics" width="518" height="393" /><p class="wp-caption-text">Complete Graphics</p></div>
<p><span id="more-158"></span>You can download the final graphics photoshop file <a href="http://jasperpotts.com/blogfiles/devox-intro-video/final-graphics.psd">here</a>, once you have this you will need Photoshop CS3 or CS4 and the JavaFX Production Suite (<a href="http://javafx.com/downloads/">download here</a>). If you don&#8217;t have Photoshop you can download a trial version to experiment with or use any design tool that will export SVG and the Production Suite convertor. Alternatively you could just save each layer as a PNG and hand code a scene graph with ImageViews for each layer. Once you have production suite installed in Photoshop you can go to &#8220;File&#8221; -&gt; &#8220;Automate&#8221; -&gt; &#8216;Save for JavaFX&#8230;&#8221; then save the graphics as &#8220;graphics.fxz&#8221; in the package directory in the source directory of a new Netbeans JavaFX project. You can then right click on the saved &#8220;fxz&#8221; file in Netbeans and choose &#8220;Generate UI Stub&#8230;&#8221; that will create a JavaFX &#8220;.fx&#8221; source file that is a scene graph Node class that you can use in your application. It will have variables for direct access to each of the layers you named in Photoshop with the &#8220;jfx:&#8221; prefix. Before you can compile the project with the newly generated stub you need to go to project properties and add the &#8220;JavaFX FXD 1.0&#8243; library to the project. Now all the code you need in Main to create a JavaFX application to display our graphics is this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">var graphics<span style="color: #339933;">:</span>graphicsUI<span style="color: #339933;">;</span>
&nbsp;
Stage <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Devoxx Video Intro&quot;</span>
    scene<span style="color: #339933;">:</span> Scene <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// PAL Video Sized</span>
        width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">768</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">576</span>
        content<span style="color: #339933;">:</span> graphics <span style="color: #339933;">=</span> graphicsUI<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
        fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So run that and check it out, cool hey! So now its time to start animating it, lets start with the background. The background is made up of 3 layers so we can animate them.</p>
<p> </p>
<div id="attachment_161" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-161" title="background" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/background.png" alt="Moody orange base background" width="318" height="243" /><p class="wp-caption-text">Moody orange base background</p></div>
<div id="attachment_162" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-162" title="clouds" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/clouds.png" alt="Clouds layer" width="318" height="243" /><p class="wp-caption-text">Clouds layer</p></div>
<div id="attachment_165" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-165" title="bar" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/bar.png" alt="Bar - grey is transparent" width="318" height="243" /><p class="wp-caption-text">Bar - grey is transparent</p></div>
<p>The clouds layer is semi transparent and we are going to animate it slowly scrolling past to add mood it sits above the moody orange background and under the black bar. The graphics for it were created to match at the ends so it can be looped without you seeing the join. I created it by using the render clouds effect in photoshop, the result I duplicated and flipped about the middle so that both ends were the same and then hand blended the join. That way I knew it would repeat without a seam. In JavaFX I am going to make a second ImageView with the clouds as I need enough to scroll completely past the visible region then jump back and start again. Here is the code for this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Make copy of clouds image view so we have enough to scroll past</span>
var cloudsGroup<span style="color: #339933;">:</span><span style="color: #003399;">Group</span> <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">clouds_group</span> as <span style="color: #003399;">Group</span><span style="color: #339933;">;</span>
var clouds1<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">clouds</span> as ImageView<span style="color: #339933;">;</span>
clouds1.<span style="color: #006633;">x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
var clouds2<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> ImageView <span style="color: #009900;">&#123;</span>
    image<span style="color: #339933;">:</span> clouds1.<span style="color: #006633;">image</span>
    translateX<span style="color: #339933;">:</span> bind clouds1.<span style="color: #006633;">image</span>.<span style="color: #006633;">width</span>
<span style="color: #009900;">&#125;</span>
insert clouds2 into cloudsGroup.<span style="color: #006633;">content</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// == Animate clouds ===========================================================</span>
TranslateTransition <span style="color: #009900;">&#123;</span>
    node<span style="color: #339933;">:</span> cloudsGroup
    fromX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span>
    toX<span style="color: #339933;">:</span> <span style="color: #339933;">-</span>clouds1.<span style="color: #006633;">image</span>.<span style="color: #006633;">width</span>
    duration<span style="color: #339933;">:</span> 10s
    autoReverse<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">false</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    interpolate<span style="color: #339933;">:</span> Interpolator.<span style="color: #006633;">LINEAR</span>
<span style="color: #009900;">&#125;</span>.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Once I have created and positioned the second could imageview I create a TranslateTransition to animate the clouds scrolling past and start it playing. Next is the 3 spotlights:</p>
<p> </p>
<div id="attachment_166" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-166" title="lights" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/lights.png" alt="Lights - 3 separate transparent layers" width="318" height="243" /><p class="wp-caption-text">Lights - 3 separate transparent layers</p></div>
<p>The spotlights will animate rotating around the center of their top. To rotate around a point other than the center of a node we will have to use a Transform and Timeline as the RotateTransition only works around the center of the node.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// == Animate lights ===========================================================</span>
var light1<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">light1</span> as ImageView<span style="color: #339933;">;</span>
var light2<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">light2</span> as ImageView<span style="color: #339933;">;</span>
var light3<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">light3</span> as ImageView<span style="color: #339933;">;</span>
var light1angle <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
var light2angle <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
var light3angle <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
light1.<span style="color: #006633;">transforms</span> <span style="color: #339933;">=</span> Rotate <span style="color: #009900;">&#123;</span> pivotX<span style="color: #339933;">:</span> light1.<span style="color: #006633;">x</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>light1.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> angle<span style="color: #339933;">:</span> bind light1angle <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
light2.<span style="color: #006633;">transforms</span> <span style="color: #339933;">=</span> Rotate <span style="color: #009900;">&#123;</span> pivotX<span style="color: #339933;">:</span> light2.<span style="color: #006633;">x</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>light2.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> angle<span style="color: #339933;">:</span> bind light2angle <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
light3.<span style="color: #006633;">transforms</span> <span style="color: #339933;">=</span> Rotate <span style="color: #009900;">&#123;</span> pivotX<span style="color: #339933;">:</span> light3.<span style="color: #006633;">x</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>light3.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> angle<span style="color: #339933;">:</span> bind light3angle <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
var light1Timeline<span style="color: #339933;">:</span>Timeline <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    keyFrames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
         at <span style="color: #009900;">&#40;</span>0s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>light1angle <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">20</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span><span style="color: #009900;">&#125;</span>
         at <span style="color: #009900;">&#40;</span>3s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>light1angle <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span><span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#93;</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    autoReverse<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
var light2Timeline<span style="color: #339933;">:</span>Timeline <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    keyFrames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
         at <span style="color: #009900;">&#40;</span>0s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>light2angle <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">20</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span><span style="color: #009900;">&#125;</span>
         at <span style="color: #009900;">&#40;</span>3.5s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>light2angle <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span><span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#93;</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    autoReverse<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
var light3Timeline<span style="color: #339933;">:</span>Timeline <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    keyFrames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
         at <span style="color: #009900;">&#40;</span>0s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>light3angle <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">25</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span><span style="color: #009900;">&#125;</span>
         at <span style="color: #009900;">&#40;</span>2.5s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>light3angle <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span><span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#93;</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    autoReverse<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The first part of the code create 3 variables &#8220;light1angle&#8221;,&#8221;light2angle&#8221; and &#8221;light3angle&#8221; then setup Rotate Tranforms on the 3 light nodes whose angle is bound to these variables. We then create 3 timelines to animate the panning of the spotlights. Note: I have not started the animations here as I will do that in the final master timeline but you can add quick &#8220;light1Timeline.play();&#8221; style lines to test it out so far.  Next is the speaker chap(dude for americans):</p>
<p> </p>
<div id="attachment_168" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-168" title="speaker" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/speaker.png" alt="Speak Chap - 2 layers head and body" width="318" height="243" /><p class="wp-caption-text">Speak Chap - 2 layers head and body</p></div>
<p>The first animation for the speaker chap is to rotate his head back and forward. This is simple as in photoshop I manipulated the center point of the layer by adding a pixel at the right point to get the center where I needed it. Because of that we can just use a simple RotateTransition:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// == Chap Head Rotation ================================================================</span>
var headRotation<span style="color: #339933;">:</span>RotateTransition <span style="color: #339933;">=</span> RotateTransition <span style="color: #009900;">&#123;</span>
    fromAngle<span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">5</span>
    toAngle<span style="color: #339933;">:</span> <span style="color: #cc66cc;">5</span>
    autoReverse<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
    duration<span style="color: #339933;">:</span> 1s
    interpolate<span style="color: #339933;">:</span> Interpolator.<span style="color: #006633;">EASEBOTH</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    node<span style="color: #339933;">:</span> graphics.<span style="color: #006633;">head</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Again I have not started this transition as it will be started at the right point in the master timeline. Next I will setup a clip on the group containing the chap&#8217;s head and body and link it to a variable that controls the beam position. This is so I can BEAM him in <img src='http://www.jasperpotts.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  for a bit of fun.</p>
<p> </p>
<div id="attachment_169" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-169" title="beam" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/beam.png" alt="Beam layer" width="318" height="243" /><p class="wp-caption-text">Beam layer</p></div>
<p>The &#8220;scanLocation&#8221; variable can be from 0.0 fully invisible to 1.0 fully visible. We will animate this later to beam the chap in.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// == Chap scan ================================================================</span>
var chap<span style="color: #339933;">:</span><span style="color: #003399;">Group</span> <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">chap</span> as <span style="color: #003399;">Group</span><span style="color: #339933;">;</span>
var chapX<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> chap.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">minX</span><span style="color: #339933;">;</span>
var chapY<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> chap.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">minY</span><span style="color: #339933;">;</span>
var chapWidth<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> chap.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">width</span><span style="color: #339933;">;</span>
var chapHeight<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> chap.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">height</span><span style="color: #339933;">;</span>
var beam<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">beam</span> as ImageView<span style="color: #339933;">;</span>
var scanLocation<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.7</span> on replace <span style="color: #009900;">&#123;</span>
    beam.<span style="color: #006633;">y</span> <span style="color: #339933;">=</span> chapY<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>chapHeight<span style="color: #339933;">*</span>scanLocation<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>beam.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">height</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
chap.<span style="color: #006633;">clip</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
    x<span style="color: #339933;">:</span> chapX
    translateY<span style="color: #339933;">:</span> bind chapY<span style="color: #339933;">-</span>chapHeight<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>chapHeight<span style="color: #339933;">*</span>scanLocation<span style="color: #009900;">&#41;</span>
    width<span style="color: #339933;">:</span> chapWidth
    height<span style="color: #339933;">:</span> chapHeight
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Next is the title text, this is made in 3 layers:</p>
<p> </p>
<div id="attachment_170" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-170" title="text" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/text.png" alt="Base text including small glow" width="318" height="243" /><p class="wp-caption-text">Base text including small glow</p></div>
<div id="attachment_171" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-171" title="text-glow" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/text-glow.png" alt="Larger glow for text" width="318" height="243" /><p class="wp-caption-text">Larger glow for text</p></div>
<div id="attachment_172" class="wp-caption alignnone" style="width: 328px"><img class="size-full wp-image-172" title="glow-mask" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/glow-mask.png" alt="Mask for large glow" width="318" height="243" /><p class="wp-caption-text">Mask for large glow</p></div>
<p>We will animate the glow mask across the text exposing a small part of the larger glow as we go, this will give the effect of a glow sweeping across the text. In the code for this I setup the mask image as a clip on the text glow layer and calculate the start and end positions for the animation.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// == Glow Mask ================================================================</span>
var glow<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">glow</span> as ImageView<span style="color: #339933;">;</span>
var glowMaskGraphics<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> graphics.<span style="color: #006633;">glowMask</span> as ImageView<span style="color: #339933;">;</span>
glowMaskGraphics.<span style="color: #006633;">visible</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
var glowX<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> glow.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">minX</span><span style="color: #339933;">;</span>
var glowWidth<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> glow.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">width</span><span style="color: #339933;">;</span>
var glowMaskWidth<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> glowMaskGraphics.<span style="color: #006633;">layoutBounds</span>.<span style="color: #006633;">width</span><span style="color: #339933;">;</span>
var glowMaskStart<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> glowX <span style="color: #339933;">-</span> glowMaskWidth<span style="color: #339933;">;</span>
var glowMaskEnd<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> glowX <span style="color: #339933;">+</span> glowWidth <span style="color: #339933;">+</span> glowMaskWidth<span style="color: #339933;">;</span>
var glowMaskPosition<span style="color: #339933;">:</span><span style="color: #003399;">Number</span> <span style="color: #339933;">=</span> glowMaskStart<span style="color: #339933;">;</span>
var glowMask<span style="color: #339933;">:</span>ImageView <span style="color: #339933;">=</span> ImageView <span style="color: #009900;">&#123;</span>
    image<span style="color: #339933;">:</span> glowMaskGraphics.<span style="color: #006633;">image</span>
    x<span style="color: #339933;">:</span> bind glowMaskPosition
    y<span style="color: #339933;">:</span> glowMaskGraphics.<span style="color: #006633;">y</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
glow.<span style="color: #006633;">clip</span> <span style="color: #339933;">=</span> glowMask<span style="color: #339933;">;</span></pre></div></div>

<p>We have a music recording from Devoxx of the beatboxer Roxorloops that we are going to use for the sound track for this intro so next we need to setup the media ready to be played.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// == Setup Music ==============================================================</span>
&nbsp;
var music<span style="color: #339933;">:</span>MediaPlayer <span style="color: #339933;">=</span> MediaPlayer <span style="color: #009900;">&#123;</span>
    media<span style="color: #339933;">:</span> Media <span style="color: #009900;">&#123;</span> source<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;http://jasperpotts.com/blogfiles/devox-intro-video/IntroBeat.mp3&quot;</span> <span style="color: #009900;">&#125;</span>
    autoPlay<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
<span style="color: #009900;">&#125;</span>
music.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That is all the setup done for the little animations, now we need to get started on the master timeline which is going to control the sequence of all the animations. First create a bunch of constants for all the times of the key points in the animation. This is handy as I can play with the timing to get it feeling right and in sync with the sound without having to dig too deeply into the code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// == Main Animation Times =====================================================</span>
def FRAME<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> 1s<span style="color: #339933;">/</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>
&nbsp;
def START<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> 5s<span style="color: #339933;">;</span>
def FIRST_LIGHT<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> START <span style="color: #339933;">+</span> 0.2s<span style="color: #339933;">;</span>
def SECOND_LIGHT<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> FIRST_LIGHT <span style="color: #339933;">+</span> 3s<span style="color: #339933;">;</span>
def THIRD_LIGHT<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> SECOND_LIGHT <span style="color: #339933;">+</span> 1s<span style="color: #339933;">;</span>
def START_SHOW_CHAP<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> THIRD_LIGHT <span style="color: #339933;">+</span> 1s<span style="color: #339933;">;</span>
def END_SHOW_CHAP<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> START_SHOW_CHAP <span style="color: #339933;">+</span> 1s<span style="color: #339933;">;</span>
def START_SHOW_TEXT<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> END_SHOW_CHAP <span style="color: #339933;">+</span> 1s<span style="color: #339933;">;</span>
def END_SHOW_TEXT<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> START_SHOW_TEXT <span style="color: #339933;">+</span> 1s<span style="color: #339933;">;</span>
def START_GLOW_SCAN<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> END_SHOW_TEXT <span style="color: #339933;">+</span> 0.5s<span style="color: #339933;">;</span>
def END_GLOW_SCAN<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> START_GLOW_SCAN <span style="color: #339933;">+</span> 5s<span style="color: #339933;">;</span>
def START_HIDE<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> END_GLOW_SCAN <span style="color: #339933;">+</span> 0.5s<span style="color: #339933;">;</span>
def END_HIDE<span style="color: #339933;">:</span>Duration <span style="color: #339933;">=</span> START_HIDE <span style="color: #339933;">+</span> 1.5s<span style="color: #339933;">;</span></pre></div></div>

<p>Then the final part is the main timeline that fades layers in and out and starts the smaller animations at the right points. This is the last of the code and you have the completed application.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// == Main Animation ===========================================================</span>
Timeline <span style="color: #009900;">&#123;</span>
    keyFrames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> 0s
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                beam.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">false</span>
                graphics.<span style="color: #006633;">bar</span>.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">false</span>
                graphics.<span style="color: #006633;">chap</span>.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">false</span>
                graphics.<span style="color: #006633;">background</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">flames</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">light1</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">light2</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">light3</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">text</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
            <span style="color: #009900;">&#93;</span>
            action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> light1Timeline.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// start second light a little later as we don't want them in sync</span>
            time<span style="color: #339933;">:</span> 1s
            action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> light2Timeline.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// start music</span>
            time<span style="color: #339933;">:</span> START <span style="color: #339933;">-</span> 0.1s
            action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                music.<span style="color: #006633;">currentTime</span> <span style="color: #339933;">=</span> 0s<span style="color: #339933;">;</span>
                music.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// start after couple seconds in as a chance to stablize after launch</span>
            time<span style="color: #339933;">:</span> START
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">background</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">flames</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">light1</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">light2</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">light3</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                graphics.<span style="color: #006633;">bar</span>.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">true</span>
            <span style="color: #009900;">&#93;</span>
            action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> light3Timeline.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> FIRST_LIGHT
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">light3</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.6</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>
&nbsp;
                graphics.<span style="color: #006633;">background</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.1</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
                graphics.<span style="color: #006633;">flames</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.1</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> SECOND_LIGHT <span style="color: #339933;">-</span> 0.2s
            values<span style="color: #339933;">:</span> graphics.<span style="color: #006633;">light1</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> SECOND_LIGHT
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">light1</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.6</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>
&nbsp;
                graphics.<span style="color: #006633;">background</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.6</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
                graphics.<span style="color: #006633;">flames</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.6</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> THIRD_LIGHT <span style="color: #339933;">-</span> 0.2s
            values<span style="color: #339933;">:</span> graphics.<span style="color: #006633;">light2</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> THIRD_LIGHT
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">light2</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.6</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>
&nbsp;
                graphics.<span style="color: #006633;">background</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
                graphics.<span style="color: #006633;">flames</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> START_SHOW_CHAP <span style="color: #339933;">-</span> 0.2s
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                beam.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
                beam.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">true</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> START_SHOW_CHAP
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">chap</span>.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">true</span>
                beam.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
                scanLocation <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> END_SHOW_CHAP
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                beam.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">false</span>
                scanLocation <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">EASEIN</span>
            <span style="color: #009900;">&#93;</span>
            action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> headRotation.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> START_SHOW_TEXT
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">text</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> END_SHOW_TEXT
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">text</span>.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span>
                graphics.<span style="color: #006633;">glow</span>.<span style="color: #006633;">visible</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000066; font-weight: bold;">true</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> START_GLOW_SCAN
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                glowMaskPosition <span style="color: #339933;">=&gt;</span> glowMaskStart
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> END_GLOW_SCAN
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                glowMaskPosition <span style="color: #339933;">=&gt;</span> glowMaskEnd tween Interpolator.<span style="color: #006633;">EASEBOTH</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> START_HIDE
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">EASEOUT</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> END_HIDE
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                graphics.<span style="color: #006633;">opacity</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span> tween Interpolator.<span style="color: #006633;">EASEOUT</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time<span style="color: #339933;">:</span> END_HIDE <span style="color: #339933;">+</span> 3s
            action<span style="color: #339933;">:</span> function <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> FX.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So we are finally there, if you have been following along then you can run what you have for the rest of you here is a web start link: </p>
<p><a href="http://jasperpotts.com/blogfiles/devox-intro-video/Devoxx_Video_Intro.jnlp" onclick="javascript:urchinTracker ('/blogfiles/devox-intro-video/Devoxx_Video_Intro.jnlp');" title="Launch Intro Video App" target="_blank"><img src="/blogfiles/launch.jpg" align="absmiddle" border="0" /></a></p>
<p> You can also download the Netbeans project complete with FXZ graphics file: <a onclick="javascript:urchinTracker ('/blogfiles/devox-intro-video/project.zip');" href="http://jasperpotts.com/blogfiles/devox-intro-video/project.zip">Netbeans Project</a>. The first session with the new intro video is already live on <a href="http://Parleys.com">Parleys.com</a> watch it here <a href="http://parleys.com/display/PARLEYS/Home#talk=23691268;slide=1;title=Inside%20the%20SpringSource%20Application%20Platform">&#8220;Inside the SpringSorce Application Platform&#8221;</a>. Well I hope you enjoyed my longest blog so far and a cool little application.</p>
<p><i><b>Update:</b> Some people have been having problems with a media bug playing the sound, I am passing it on to the Media Team in the mean time here is a webstart link without music:</i></p>
<p><a href="http://jasperpotts.com/blogfiles/devox-intro-video/Devoxx_Video_Intro_NoMusic.jnlp" onclick="javascript:urchinTracker ('/blogfiles/devox-intro-video/Devoxx_Video_Intro_NoMusic.jnlp');" title="Launch Intro Video App" target="_blank"><img src="/blogfiles/launch.jpg" align="absmiddle" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasperpotts.com/blog/2009/01/devoxxparleyscom-intro-video/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
<enclosure url="http://jasperpotts.com/blogfiles/devox-intro-video/IntroBeat.mp3" length="256586" type="audio/mpeg" />
		</item>
		<item>
		<title>Introduction to JavaFX Talks &#8211; Devoxx 2008 &#8211; IJTC 2009</title>
		<link>http://www.jasperpotts.com/blog/2009/01/introduction-to-javafx-talks-devoxx-2008-ijtc-2009/</link>
		<comments>http://www.jasperpotts.com/blog/2009/01/introduction-to-javafx-talks-devoxx-2008-ijtc-2009/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 12:28:15 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JavaFXApplications]]></category>

		<guid isPermaLink="false">http://www.jasperpotts.com/blog/?p=139</guid>
		<description><![CDATA[Over the last couple months Richard Bair, Martin Brehovsky and I presented talks introducing JavaFX at Devoxx 2008, Sun Paris Tech Day and IJTC 2009 (Irish Java Technologies Conference). There are 2 versions a longer one for Devoxx and a more condensed version for Paris and IJTC. For those of you interested here are the slides and demos:
Slides

Devoxx Slides [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last couple months <a title="Richard's Blog" href="http://weblogs.java.net/blog/rbair/">Richard Bair</a>, Martin Brehovsky and I presented talks introducing JavaFX at <a title="Devoox" href="http://www.devoxx.com/display/JV08/Home">Devoxx 2008</a>, Sun Paris Tech Day and <a href="http://ijtc.firstport.ie/">IJTC 2009</a> (Irish Java Technologies Conference). There are 2 versions a longer one for Devoxx and a more condensed version for Paris and IJTC. For those of you interested here are the slides and demos:</p>
<h3>Slides</h3>
<p><a class="wp-caption" title="Devoxx Slides" onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/javafx-devoxx.pdf');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/javafx-devoxx.pdf"><img class="alignnone size-full wp-image-140" title="devoxx-slide" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/devoxx-slide.png" alt="devoxx-slide" width="408" height="309" /></a></p>
<p><a class="wp-caption" title="Devoxx Slides" onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/javafx-devoxx.pdf');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/javafx-devoxx.pdf">Devoxx Slides PDF</a></p>
<p><a class="wp-caption" title="IJTC Slides" onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/javafx-ijtc.pdf');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/javafx-ijtc.pdf"><img class="alignnone size-full wp-image-141" title="ijtc slide" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/slide.png" alt="ijtc slide" width="408" height="308" /></a></p>
<p><a class="wp-caption" title="IJTC Slides" onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/javafx-ijtc.pdf');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/javafx-ijtc.pdf">IJTC Slides PDF</a></p>
<h3>Demo</h3>
<p>During the talks we built up a simple demo with what you learn in each section.</p>
<p><img class="alignnone size-full wp-image-143" title="talk-demo" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/talk-demo.png" alt="talk-demo" width="500" height="363" /></p>
<p>Here are the links so you can webstart the demos for the different sections, I started at Demo 2d as that is the first version with working close button which is always helpful <img src='http://www.jasperpotts.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/Talk_Demo2.jnlp');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/Talk_Demo2.jnlp"><img class="alignnone size-full wp-image-144" title="talk-demo-2d" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/talk-demo-2d.png" alt="talk-demo-2d" width="180" height="194" /></a><a onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/Talk_Demo3.jnlp');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/Talk_Demo3.jnlp"><img class="alignnone size-full wp-image-145" title="talk-demo-3" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/talk-demo-3.png" alt="talk-demo-3" width="180" height="194" /></a></p>
<p><a onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/Talk_Demo3.jnlp');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/Talk_Demo3.jnlp"></a><a onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/Talk_Demo4.jnlp');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/Talk_Demo4.jnlp"><img class="alignnone size-full wp-image-146" title="talk-demo-4" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/talk-demo-4.png" alt="talk-demo-4" width="180" height="194" /></a><a onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/Talk_Demo5.jnlp');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/Talk_Demo5.jnlp"><img class="alignnone size-full wp-image-147" title="talk-demo-5" src="http://www.jasperpotts.com/blog/wp-content/uploads/2009/01/talk-demo-5.png" alt="talk-demo-5" width="180" height="194" /></a></p>
<p>Here is the Netbeans project and source files for these demos so you can play with them.</p>
<p><a title="talk-demo.zip" onclick="javascript:urchinTracker ('/blogfiles/javafx-intro-talk/talk-demo.zip');" href="http://jasperpotts.com/blogfiles/javafx-intro-talk/talk-demo.zip">Netbeans-Project.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasperpotts.com/blog/2009/01/introduction-to-javafx-talks-devoxx-2008-ijtc-2009/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>JavaFX Sketching Application</title>
		<link>http://www.jasperpotts.com/blog/2009/01/javafx-sketching-application/</link>
		<comments>http://www.jasperpotts.com/blog/2009/01/javafx-sketching-application/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 20:01:00 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JavaFXApplications]]></category>

		<guid isPermaLink="false">http://www.jasperpotts.com/blog/?p=90</guid>
		<description><![CDATA[A friend forwarded a email to me a couple days ago from a researcher who wanted to record children sketching on a computer using a graphics tablet. So they could play it back later and watch how they did it etc. It sounded like a cool little app and as I was bored while waiting [...]]]></description>
			<content:encoded><![CDATA[<p>A friend forwarded a email to me a couple days ago from a researcher who wanted to record children sketching on a computer using a graphics tablet. So they could play it back later and watch how they did it etc. It sounded like a cool little app and as I was bored while waiting for a plane back from the IJTC conferance I thought I would have a quick go, how hard can it be <img src='http://www.jasperpotts.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><span id="more-90"></span>So here is what I had after a couple hours:</p>
<p><script src="http://dl.javafx.com/dtfx.js"></script><br />
 <script type="text/javascript"><!--
     javafx({archive: "http://jasperpotts.com/blogfiles/sketch/Sketch.jar",width: 600,height: 450,code: "sketch.Main",name: "Sketch"});
// --></script></p>
<p>The biggest challenge I had was to stop adding more and more features as it was so easy. If I do some more then I would like to make it save to my website so I can have a gallery of what people have created that other people can replay, maybe next time I have a flight I will do that.</p>
<p>To start with I just wanted to create a simple canvas that I could scribble on and see how it worked, I was suprised how simple it was. Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Stage<span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Sketch&quot;</span>
    scene<span style="color: #339933;">:</span>
    scene <span style="color: #339933;">=</span> Scene<span style="color: #009900;">&#123;</span>
        width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">400</span>
        height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">400</span>
        content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            lines
            <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
                width<span style="color: #339933;">:</span> bind scene.<span style="color: #006633;">width</span>
                height<span style="color: #339933;">:</span> bind scene.<span style="color: #006633;">height</span>
                fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">TRANSPARENT</span>
                onMousePressed<span style="color: #339933;">:</span> function <span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    insert currentPath <span style="color: #339933;">=</span> Path<span style="color: #009900;">&#123;</span>
                        elements<span style="color: #339933;">:</span> MoveTo<span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> e.<span style="color: #006633;">x</span> y<span style="color: #339933;">:</span> e.<span style="color: #006633;">y</span> <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span> into lines.<span style="color: #006633;">content</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                onMouseDragged<span style="color: #339933;">:</span> function <span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    insert LineTo<span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> e.<span style="color: #006633;">x</span> y<span style="color: #339933;">:</span> e.<span style="color: #006633;">y</span> <span style="color: #009900;">&#125;</span> into currentPath.<span style="color: #006633;">elements</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                onMouseReleased<span style="color: #339933;">:</span> function <span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    insert LineTo<span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> e.<span style="color: #006633;">x</span> y<span style="color: #339933;">:</span> e.<span style="color: #006633;">y</span> <span style="color: #009900;">&#125;</span> into currentPath.<span style="color: #006633;">elements</span><span style="color: #339933;">;</span>
                    currentPath <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It works pretty well for such a basic way of doing it but is limited by the frequency at which it receives mouse events. Interestingly it works way better with a graphics tablet than a mouse as you seem to get many more events. There are also some Java libraries out there for interfacing with graphics tablets to get pressure and tilt information so we could link that in to vary the stroke width for example. I also thought about algorithms that could convert the series of points into smooth curves. There are loads of cool things that could be done with this but it is amazing how useable the dumb/simple version is.</p>
<p>If you would like the Netbeans project with the source so you can play with it <a title="Spline Editor Src" onclick="javascript:urchinTracker ('/blogfiles/sketch/Sketch.zip');" href="http://jasperpotts.com/blogfiles/sketch/Sketch.zip" target="_blank">Dowload Here</a>. If you have any extra features you add please send them to me and I will post a new version. If there is much interest then we could create a opensource project for a JavaFX Painting application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasperpotts.com/blog/2009/01/javafx-sketching-application/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>JavaFX Spline Editor</title>
		<link>http://www.jasperpotts.com/blog/2009/01/javafx-spline-editor/</link>
		<comments>http://www.jasperpotts.com/blog/2009/01/javafx-spline-editor/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 11:04:56 +0000</pubDate>
		<dc:creator>Jasper Potts</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JavaFXApplications]]></category>

		<guid isPermaLink="false">http://www.jasperpotts.com/blog/2009/01/javafx-spline-editor/</guid>
		<description><![CDATA[When I was creating the prize draw application I needed to work out the Spline interpreter numbers to make the names thud down. I ended up using Romain Guy&#8217;s Spline Editor for Swing which makes it nice and easy. So thought it was about time we had a JavaFX version, and it could not be [...]]]></description>
			<content:encoded><![CDATA[<p>When I was creating the prize draw application I needed to work out the Spline interpreter numbers to make the names thud down. I ended up using <a href="http://www.jroller.com/gfx/entry/swing_demos_animations_and_swing">Romain Guy&#8217;s Spline Editor for Swing</a> which makes it nice and easy. So thought it was about time we had a JavaFX version, and it could not be too hard. So a couple hours and a couple hundred bind statements later we have a very cool little Spline Editor that lets you edit the spline and see the effect in real time then copy the code to paste into your JavaFX application.</p>
<p><img src="http://www.jasperpotts.com/blog/wp-content/uploads/2008/12/splineeditor.jpg" alt="Spline Editor" /></p>
<p>If you would like to try it for your self click here: <a href="http://jasperpotts.com/blogfiles/splineeditor/Spline_Editor.jnlp" onclick="javascript:urchinTracker ('/blogfiles/splineeditor/Spline_Editor.jnlp');" title="Launch Spline Editor" target="_blank"><img src="/blogfiles/launch.jpg" align="absmiddle" border="0" /></a> you can also download the <a href="http://jasperpotts.com/blogfiles/splineeditor/src.zip" onclick="javascript:urchinTracker ('/blogfiles/splineeditor/src.zip');" title="Spline Editor Src" target="_blank">source Netbeans project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasperpotts.com/blog/2009/01/javafx-spline-editor/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
