<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">What are the right codes?</title><subtitle type="html" /><id>http://blogs.msdn.com/tim_rice/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/tim_rice/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/tim_rice/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2008-01-11T16:27:00Z</updated><entry><title>Popfly Silverlight Display Blocks 102</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/tim_rice/archive/2008/01/16/popfly-silverlight-display-blocks-102.aspx" /><id>http://blogs.msdn.com/tim_rice/archive/2008/01/16/popfly-silverlight-display-blocks-102.aspx</id><published>2008-01-16T21:33:00Z</published><updated>2008-01-16T21:33:00Z</updated><content type="html">&lt;P&gt;In my &lt;A class="" title="previous post" href="http://blogs.msdn.com/tim_rice/archive/2008/01/11/popfly-silverlight-display-blocks-101.aspx" mce_href="http://blogs.msdn.com/tim_rice/archive/2008/01/11/popfly-silverlight-display-blocks-101.aspx"&gt;previous post&lt;/A&gt; we made a simple Popfly Silverlight display block.&amp;nbsp; Now we can do something a little more interesting. All of these examples will use the block description from the previous post, so be sure to take a look.&lt;/P&gt;
&lt;H2&gt;Making a Slideshow&lt;/H2&gt;
&lt;P&gt;We can make a simple slideshow by fading from one picture to the next. Take a look at the "HelloSilverlight-3" block:&lt;/P&gt;
&lt;P&gt;&lt;IFRAME style="WIDTH: 320px; HEIGHT: 200px" src="http://www.popfly.com/users/tim/HelloSilverlightMashup-3.small" frameBorder=no allowTransparency&gt;&lt;/IFRAME&gt;&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; HelloWorld()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;HelloWorld.initializeBase(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index = -1; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// index of image being animated&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;}&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.getXaml = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// make a 640x480 canvas&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;lt;Canvas Width="640" Height="480"/&amp;gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;;&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.addImage = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(url)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// start loading the image&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.addPendingImage(url);&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.imageLoaded = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(image)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// get our canvas&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.root.children.getItem(0);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// xaml for the image display and animation&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; xaml =&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;lt;Image Name="image" Opacity="0" Width="640" Height="480" Stretch="UniformToFill"&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;lt;Image.Resources&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Storyboard Name="fadeIn" Duration="0:0:5"&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="image" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:1"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Storyboard&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Storyboard Name="fadeOut" Duration="0:0:1"&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="image" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:1"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Storyboard&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;lt;/Image.Resources&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;lt;/Image&amp;gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// create the object and set the image source&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; object = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.content.createFromXaml(xaml, &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;object.source = image.source;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// call the onCompleted handler when the image is done animating&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;object.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"fadeIn"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).addEventListener(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"completed"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, delegate(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.onCompleted));&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// add the image to our canvas&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas.children.add(object);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// if this is the first image, start the animation&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index == -1)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.showNextImage();&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.showNextImage = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// get the next image&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index++;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas.children.count)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; image = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas.children.getItem(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// zoom the image in&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;image.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"fadeIn"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).begin();&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.onCompleted = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(sender)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// start fading the image out&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;sender.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"fadeOut"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).begin();&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// show the next image&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.showNextImage();&amp;nbsp;&amp;nbsp;&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.registerClass(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'HelloWorld'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, Popfly.Blocks.SilverBase);&lt;BR&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;HelloSilverlight-3 Code&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;We added a few things here to the previous example here. The getXaml call lets us say how big of a canvas we want to work with because it gets automatically added to the root canvas of our Silverlight control . Note that this will automatically get scaled to fit the user's browser optimally. In the imageLoaded callback we added a bunch of xaml to do the fading in and out. We then create an object using that xaml, get a callback to see when the image has faded in, add the image to the canvas, and show it.&lt;/P&gt;
&lt;P&gt;The showNextImage function figures out which image is next and starts fading it in. Once the fadeIn has completed, the onCompleted function starts fading it out and starts fading the next one in. Lather, rinse, repeat! Straightforward enough? Is the xaml a little confusing? Let’s break it down:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Image&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;image&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Opacity&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;640&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;480&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Stretch&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;UniformToFill&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;Here we declare our image in xaml with the name "image" so we can easily reference it in the animations, and set the opacity to 0 so it starts out hidden. We also give it a height and width and ask Silverlight to fill that space with our image. That's what "UniformToFill" basically means.&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;fadeIn&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Duration&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;0:0:5&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DoubleAnimation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;image&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Opacity&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Duration&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;0:0:1&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;The two storyboards are similar. One fades the image in, the other fades it out. Note the duration of the fadeIn storyboard is 5 seconds but the DoubleAnimation inside it only lasts 1 second. This is so we can actually see the image for a full 4 seconds before the onCompleted function in our code is called, and we start to fade the image back out.&lt;/P&gt;
&lt;P&gt;If you are wondering how the fadeIn storyboard actually calls the onCompleted function in the code, the answer is simple. We add a listener for the storyboard's completed event and make it call our function, like so:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: green"&gt;// call the onCompleted handler when the image is done animating&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;object.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"fadeIn"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).addEventListener(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"completed"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, delegate(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.onCompleted));&lt;BR&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;H2&gt;Animating Slideshow&lt;/H2&gt;
&lt;P&gt;&lt;IFRAME style="WIDTH: 320px; HEIGHT: 200px" src="http://www.popfly.com/users/tim/HelloSilverlightMashup-4.small" frameBorder=no allowTransparency&gt;&lt;/IFRAME&gt;&lt;/P&gt;
&lt;P&gt;The Ken Burns Effect might be familiar to you; it's basically zooming in and moving the pictures around to make them seem more alive. Let's extend the previous example to do this. (HelloSilverlight-4)&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; HelloWorld()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;HelloWorld.initializeBase(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index = -1; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// index of image being animated&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;}&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.getXaml = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// make a 400x400 canvas and clip everything to it&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;lt;Canvas Width="640" Height="480" Clip="M0,0 H640 V480 H0z"/&amp;gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;;&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.addImage = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(url)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// start loading the image&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.addPendingImage(url);&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.imageLoaded = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(image)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// get our canvas&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.root.children.getItem(0);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// pick a random spot to zoom the image to / from&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; left = Math.random()*-100;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; top = Math.random()*-100;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; zoomFrom, zoomTo;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(Math.random()&amp;gt;0.5)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zoomFrom = Math.random()*0.4 + 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zoomTo = 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;} &lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zoomFrom = 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zoomTo = Math.random()*0.4 + 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// xaml for the image display and animation&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; xaml =&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;lt;Image Name="image" Opacity="0" Width="740" Height="580" Stretch="UniformToFill"&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;lt;Image.Resources&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Storyboard Name="fadeIn" Duration="0:0:5"&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="image" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:1"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Storyboard&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Storyboard Name="zoom"&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="translate" Storyboard.TargetProperty="X" From="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ top +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" To="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ left +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" Duration="0:0:6"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="translate" Storyboard.TargetProperty="Y" From="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ left +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" To="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ top +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" Duration="0:0:6"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" From="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ zoomFrom +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" To="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ zoomTo +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" Duration="0:0:6"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" From="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ zoomFrom +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" To="'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;+ zoomTo +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'" Duration="0:0:6"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Storyboard&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Storyboard Name="fadeOut" Duration="0:0:1"&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;DoubleAnimation Storyboard.TargetName="image" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:1"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Storyboard&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;lt;/Image.Resources&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;lt;Image.RenderTransform&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;TransformGroup&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;TranslateTransform Name="translate"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ScaleTransform Name="scale"/&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/TransformGroup&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;nbsp;&amp;nbsp;&amp;lt;/Image.RenderTransform&amp;gt;'&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;lt;/Image&amp;gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// create the object and set the image source&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; object = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.content.createFromXaml(xaml, &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;object.source = image.source;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// call the onCompleted handler when the image is done animating&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;object.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"fadeIn"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).addEventListener(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"completed"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, delegate(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.onCompleted));&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// add the image to our canvas&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas.children.add(object);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// if this is the first image, start the animation&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index == -1)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.showNextImage();&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.showNextImage = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// get the next image&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index++;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas.children.count)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; image = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.canvas.children.getItem(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.index);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// zoom the image in&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;image.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"fadeIn"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).begin();&lt;BR&gt;&amp;nbsp;&amp;nbsp;image.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"zoom"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).begin();&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.onCompleted = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(sender)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// start fading the image out&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;sender.findName(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"fadeOut"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;).begin();&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// show the next image&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.showNextImage();&amp;nbsp;&amp;nbsp;&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.registerClass(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'HelloWorld'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, Popfly.Blocks.SilverBase);&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;HelloSilverlight-4 Code&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;There's only a few additional lines in this example. We pick a random spot, figure out whether to zoom in or out, create the animation and transforms for it, and then run!&lt;/P&gt;
&lt;H2&gt;Where Can You Go From Here?&lt;/H2&gt;
&lt;P&gt;Here's some things you could add to the block:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;More animation effects (rotating, squashing, coloring)&lt;/LI&gt;
&lt;LI&gt;Captions and descriptions&lt;/LI&gt;
&lt;LI&gt;Sound effects&lt;/LI&gt;
&lt;LI&gt;Show multiple pictures side-by-side&lt;/LI&gt;
&lt;LI&gt;Frames&lt;/LI&gt;
&lt;LI&gt;Mouse interactivity&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Check out some of the other display blocks, such as "photoPile" for more ideas...&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7133562" width="1" height="1"&gt;</content><author><name>Tim Rice</name><uri>http://blogs.msdn.com/members/Tim+Rice.aspx</uri></author><category term="JavaScript" scheme="http://blogs.msdn.com/tim_rice/archive/tags/JavaScript/default.aspx" /><category term="Popfly" scheme="http://blogs.msdn.com/tim_rice/archive/tags/Popfly/default.aspx" /><category term="Silverlight" scheme="http://blogs.msdn.com/tim_rice/archive/tags/Silverlight/default.aspx" /></entry><entry><title>Popfly Silverlight Display Blocks 101</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/tim_rice/archive/2008/01/11/popfly-silverlight-display-blocks-101.aspx" /><id>http://blogs.msdn.com/tim_rice/archive/2008/01/11/popfly-silverlight-display-blocks-101.aspx</id><published>2008-01-12T03:27:00Z</published><updated>2008-01-12T03:27:00Z</updated><content type="html">&lt;P&gt;&lt;A href="http://www.popfly.com/"&gt;Popfly&lt;/A&gt; and &lt;A href="http://www.silverlight.net/"&gt;Silverlight&lt;/A&gt; make it easy to show your pictures from many places in slick little gadgets. It's easy, and fun to make these "display blocks". I wanted to do a little walkthrough of creating a display block. The examples herein are actual Popfly mashups. They do use Silverlight, so make sure you get that installed.&lt;/P&gt;
&lt;P&gt;This first blog entry will go over a couple of simple examples. But the next entry will show how to build a moving slideshow like this:&lt;/P&gt;
&lt;P&gt;&lt;IFRAME style="WIDTH: 320px; HEIGHT: 200px" src="http://www.popfly.com/users/tim/HelloSilverlightMashup-4.small" frameBorder=no allowTransparency mce_src="http://www.popfly.com/users/tim/HelloSilverlightMashup-4.small"&gt;&lt;/IFRAME&gt;&lt;/P&gt;
&lt;H2&gt;Getting Started&lt;/H2&gt;
&lt;P&gt;To follow along, you'll need:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Some JavaScript knowledge (not a lot!) (Bookmark MSDN's &lt;A href="http://msdn2.microsoft.com/en-us/library/yek4tbz0.aspx"&gt;JavaScript Reference&lt;/A&gt;)&lt;/LI&gt;
&lt;LI&gt;Some Silverlight knowledge. There are some great &lt;A href="http://www.amazon.com/Silverlight-1-0-Unleashed-Adam-Nathan/dp/0672330075"&gt;books&lt;/A&gt; to help you here! (Bookmark MSDN's &lt;A href="http://msdn2.microsoft.com/en-us/library/bb188567.aspx"&gt;Silverlight Reference&lt;/A&gt;)&lt;/&lt; li&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;H2&gt;Hello, World!&lt;/H2&gt;
&lt;P&gt;&lt;IFRAME style="WIDTH: 320px; HEIGHT: 200px" src="http://www.popfly.com/users/tim/HelloSilverlightMashup-1.small" frameBorder=no mce_src="http://www.popfly.com/users/tim/HelloSilverlightMashup-1.small"&gt;&lt;/IFRAME&gt;&lt;/P&gt;
&lt;P&gt;Let's look at this lame Hello World example to get some boilerplate out of the way. Here's the entire JavaScript code for it:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; HelloWorld()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;HelloWorld.initializeBase(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;);&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.getXaml = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"&amp;lt;TextBlock&amp;gt;Hello World!&amp;lt;/TextBlock&amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;;&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.Hello = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Nothing to do!&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.registerClass(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'HelloWorld'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, Popfly.Blocks.SilverBase);&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;Figure 1 - HelloSilverlight-1 Code&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Pretty easy! The initializeBase and registerClass functions are important, they say that you are writing a display block and want to use “SilverBase”. SilverBase takes care of creating the Silverlight control, centering, stretching, loading images, and a lot more so you can just do the good stuff!&lt;/P&gt;
&lt;P&gt;The only other thing needed is the block description. For Hello World, it looks like this:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;xml&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;1.0&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;?&amp;gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;block&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns:xsi&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xsi:noNamespaceSchemaLocation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;http://www.popfly.com/schemas/blockschema.xsd&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;HelloWorld&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;hasInitialize&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;display&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operations&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Hello&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;Display Hello World Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operations&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;objects&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;block&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;Figure 2 - HelloSilverlight-1 Description&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;H2&gt;Images&lt;/H2&gt;
&lt;P&gt;Showing an image:&lt;/P&gt;
&lt;P&gt;&lt;IFRAME style="WIDTH: 320px; HEIGHT: 200px" src="http://www.popfly.com/users/tim/HelloSilverlightMashup-2.small" frameBorder=no allowTransparency mce_src="http://www.popfly.com/users/tim/HelloSilverlightMashup-2.small"&gt;&lt;/IFRAME&gt;&lt;/P&gt;
&lt;P&gt;The entire code for this simple display is as follows:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt; HelloWorld()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;HelloWorld.initializeBase(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;);&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.addImage = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(url)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.addPendingImage(url);&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.prototype.imageLoaded = &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;(image)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;.root.children.add(image);&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;HelloWorld.registerClass(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'HelloWorld'&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;, Popfly.Blocks.SilverBase);&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;Figure 3 - HelloSilverlight-2 Code&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;We added an operation, "addImage". It takes an image URL as a parameter and adds that as a "pending image" to SilverBase. When the image has been completely loaded, SilverBase calls your function, “imageLoaded” with the actual loaded image. So then we add it as a child to the root canvas. Done!&lt;/P&gt;
&lt;P&gt;Run this and you’ll see a picture in the upper left. You can easily move it around by setting image["Canvas.Left"] and image["Canvas.Top"]. This and both of tomorrow's examples will use the same block description xml as show below.&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Monospace; BACKGROUND-COLOR: #dddddd"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;xml&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;1.0&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;?&amp;gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;block&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns:xsi&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xsi:noNamespaceSchemaLocation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;http://www.popfly.com/schemas/blockschema.xsd&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;HelloWorld&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;hasInitialize&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;display&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operations&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;addImage&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;Add an image&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;inputs&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;input&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;url&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;required&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;imageUrl&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;A URL pointing to an image&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;defaultValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;http://www.popfly.ms/Images/community_globe.jpg&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;defaultValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;input&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;inputs&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;operations&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;objects&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;block&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Calibri color=#4f81bd&gt;Figure&amp;nbsp;4 - HelloSilverlight-2..4 Description&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;So far, so good? In my next blog entry we'll see how to make simple slideshows. You can get a preview of these by editing the mashup at the top of this entry. &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7082573" width="1" height="1"&gt;</content><author><name>Tim Rice</name><uri>http://blogs.msdn.com/members/Tim+Rice.aspx</uri></author><category term="JavaScript" scheme="http://blogs.msdn.com/tim_rice/archive/tags/JavaScript/default.aspx" /><category term="Popfly" scheme="http://blogs.msdn.com/tim_rice/archive/tags/Popfly/default.aspx" /><category term="Silverlight" scheme="http://blogs.msdn.com/tim_rice/archive/tags/Silverlight/default.aspx" /></entry></feed>