<?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>ClickPopMedia &#187; Gallery</title>
	<atom:link href="http://www.clickpopmedia.com/tag/gallery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clickpopmedia.com</link>
	<description>ClickPopMedia is a great little design and illustration firm.</description>
	<lastBuildDate>Thu, 03 Dec 2009 17:28:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating an XML Gallery with ActionScript 3.0</title>
		<link>http://www.clickpopmedia.com/2008/05/14/creating-an-xml-gallery-with-actionscript-30/</link>
		<comments>http://www.clickpopmedia.com/2008/05/14/creating-an-xml-gallery-with-actionscript-30/#comments</comments>
		<pubDate>Thu, 15 May 2008 02:37:28 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[Just for Fun!]]></category>
		<category><![CDATA[Paul]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[VQ]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Gallery]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.clickpopmedia.com/?p=309</guid>
		<description><![CDATA[For any dynamic Flash project, XML will be a powerful tool.  One of the most common examples (and one of the simplest) is a picture gallery like the one I have here:

Images came from http://www.stockvault.net/
I will be talking about how to use Flash and XML to make a simple, yet superfly, gallery.

So, let us [...]]]></description>
			<content:encoded><![CDATA[<p>For any dynamic Flash project, XML will be a powerful tool.  One of the most common examples (and one of the simplest) is a picture gallery like the one I have here:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="700" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.clickpopmedia.com/wp-content/uploads/2008/05/xmlgallery.swf" /><embed type="application/x-shockwave-flash" width="600" height="700" src="http://www.clickpopmedia.com/wp-content/uploads/2008/05/xmlgallery.swf"></embed></object><br />
<em>Images came from <a href="http://www.stockvault.net/">http://www.stockvault.net/</a></em></p>
<p>I will be talking about how to use Flash and XML to make a simple, yet superfly, gallery.<br />
<span id="more-309"></span><br />
So, let us  start off by looking at my XML file&#8217;s structure:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="sc3"><span class="re1">&lt;gallery</span> <span class="re0">dir</span>=<span class="st0">&quot;//url/Photos/&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;0&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_7030_20070301.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;375&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cute Puppy! &nbsp;Who couldn&#8217;t love that face?<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;1&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_4095_20070301.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;375&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Three Friendly Cats.<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;2&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_4281_20070301.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;375&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; The Terror of the UnderSofa!<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;3&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_6257_20070301.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;375&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bored? Let&#8217;s play catch!<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;4&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_6882_20070301.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;377&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; It may be natural, but this picture still feels weird to me.<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;5&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_7241_20070301.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;375&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; My cats hate the snow.<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;6&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_7538_20070507.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;622&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;![CDATA[&lt;I&gt;LOOK&lt;/I&gt; IT'S &lt;B&gt;HTML&lt;/B&gt;!!!]]&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;img</span> <span class="re0">id</span>=<span class="st0">&#8216;7&#8242;</span> <span class="re0">file</span>=<span class="st0">&quot;photo_7915_20070609.jpg&quot;</span> <span class="re0">width</span>=<span class="st0">&#8216;500&#8242;</span> <span class="re0">height</span>=<span class="st0">&#8216;371&#8242;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Skinny cats are OK too.<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/img<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/gallery<span class="re2">&gt;</span></span></span></div>
<p>XML is very simple to understand if you know anything about HTML&#8217;s tag structure.  The XML document has a root <strong>tag</strong> &lt;gallery&gt; that has an <strong>attribute</strong> dir=&#8221;//url/Photos/&#8221;.  Every tag has to be closed within it&#8217;s own level of the tree.   Our gallery tag is closed at the bottom of the document with <strong>&lt;/gallery&gt;</strong>.   This means that all the  <strong>&lt;img&gt;</strong> tags are elements inside the gallery element (both open and close tags combined make up an element).</p>
<p>Our <strong>&lt;img&gt;</strong> tags have several attributes, such as the images file name and it&#8217;s pixel demensions.  Inside each <strong>&lt;img&gt;</strong> element we have a short comment about the image that will be displayed in a TextField in our Flash movie.</p>
<blockquote><p>One important thing to notice here is that if you want to have HTML in your TextField then you need to tell the code that something is a string containing HTML and not more elements.  We do this with a special bracket &lt;![CDATA[  <em>HTML GOES HERE</em> ]]&gt;  Isn&#8217;t that GREAT!  That right there probably made this whole tutorial worth while (that was a problem that took me a long time to solve).</p></blockquote>
<p>OK, now that we&#8217;ve looked at the XML we need to make it work with ActionScript 3. In Adobe Flash CS3 I created a new AS3 FLA doc and a new AS doc.  In the FLA I simply created some very basic MovieClips for my left and right arrows and I placed a TextField at the bottom of my stage (which I set to 600 X 700 with a black background).  After naming my instances and setting up the Document Class linkage I was done with the FLA side of thing and the rest is ActionScript.</p>
<p>Our Document Class has to extend MovieClip so we take our first steps thusly:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw3">public</span> <span class="kw2">class</span> Main <span class="kw3">extends</span> <span class="kw3">MovieClip</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">var</span> currentImg:<span class="kw3">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">var</span> lastImg:<span class="kw3">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">var</span> <span class="kw3">xml</span>:<span class="kw3">XML</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">var</span> loader:Loader;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">var</span> xmlLoader:URLLoader;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">public</span> <span class="kw2">function</span> Main<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loader = <span class="kw2">new</span> Loader<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span class="br0">&#40;</span>loader<span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlLoader = <span class="kw2">new</span> URLLoader<span class="br0">&#40;</span><span class="kw2">new</span> URLRequest<span class="br0">&#40;</span><span class="st0">&quot;//url/gallery.xml&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlLoader.<span class="me1">addEventListener</span><span class="br0">&#40;</span>Event.<span class="me1">COMPLETE</span>, <span class="kw3">parseXML</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left_mc.<span class="kw3">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="co1">//Need to stop the arrows from flickering</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; right_mc.<span class="kw3">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>In our constructor we are initializing our Loader which will contain the loaded images and we are loading our XML document.  When the XML doc is done loading, the function parseXML will handle the content.</p>
<div class="dean_ch" style="white-space: wrap;">protected <span class="kw2">function</span> <span class="kw3">parseXML</span><span class="br0">&#40;</span>event:Event<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; left_mc.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_UP</span>, nextImg<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; left_mc.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_OUT</span>, arrowOut<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; left_mc.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_OVER</span>, arrowOver<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; right_mc.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_UP</span>, prevImg<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; right_mc.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_OUT</span>, arrowOut<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; right_mc.<span class="me1">addEventListener</span><span class="br0">&#40;</span>MouseEvent.<span class="me1">MOUSE_OVER</span>, arrowOver<span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">xml</span> = <span class="kw2">new</span> <span class="kw3">XML</span><span class="br0">&#40;</span>event.<span class="me1">currentTarget</span>.<span class="kw3">data</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; lastImg = <span class="kw3">xml</span>.<span class="me1">img</span>.<span class="kw3">length</span><span class="br0">&#40;</span><span class="br0">&#41;</span> &#8211; <span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentImg = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; loadImg<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>I&#8217;ve recently gotten into the habit of using protected functions rather then private functions.  There is only one difference between the two and that&#8217;s that private <em>anything</em> won&#8217;t be inherited by child classes.<br />
In this function I set the MouseEvents for the arrows because if the XML failed to load, there would be no reason for the arrows to work.</p>
<p>Alright, so I saved my XML tree in the var <strong>xml</strong> for ease of use later.  I also saved the number of images in my XML doc using the <strong>length()</strong> method.  Something to know about the length method is it will only tell you how many elements there are of that tag type at that level.  For example, if I were to have child elements inside my <strong>img</strong> elements that would not affect the return value of <strong>xml.img.length();</strong> It&#8217;s only telling you how many img elements are children of <strong>gallery</strong> (<strong>gallery</strong> is accessed with the var <strong>xml</strong> directly).</p>
<div class="dean_ch" style="white-space: wrap;">protected <span class="kw2">function</span> loadImg<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; loader.<span class="me1">x</span> = <span class="br0">&#40;</span><span class="kw3">stage</span>.<span class="kw3">width</span> &#8211; <span class="kw3">Number</span><span class="br0">&#40;</span><span class="kw3">xml</span>.<span class="me1">img</span><span class="br0">&#91;</span>currentImg<span class="br0">&#93;</span>.@<span class="kw3">width</span><span class="br0">&#41;</span><span class="br0">&#41;</span>/<span class="nu0">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; loader.<span class="me1">y</span> = <span class="br0">&#40;</span><span class="kw3">stage</span>.<span class="kw3">height</span> &#8211; <span class="nu0">50</span> &#8211; <span class="kw3">Number</span><span class="br0">&#40;</span><span class="kw3">xml</span>.<span class="me1">img</span><span class="br0">&#91;</span>currentImg<span class="br0">&#93;</span>.@<span class="kw3">height</span><span class="br0">&#41;</span><span class="br0">&#41;</span>/<span class="nu0">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; loader.<span class="kw3">load</span><span class="br0">&#40;</span><span class="kw2">new</span> URLRequest<span class="br0">&#40;</span><span class="kw3">xml</span>.@dir + <span class="kw3">xml</span>.<span class="me1">img</span><span class="br0">&#91;</span>currentImg<span class="br0">&#93;</span>.@file<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; loader.<span class="me1">contentLoaderInfo</span>.<span class="me1">addEventListener</span><span class="br0">&#40;</span>Event.<span class="me1">COMPLETE</span>, loadFin<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
protected <span class="kw2">function</span> loadFin<span class="br0">&#40;</span>event:Event<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; textDisp_TF.<span class="kw3">htmlText</span> = <span class="kw3">xml</span>.<span class="me1">img</span><span class="br0">&#91;</span>currentImg<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
<p>In that first function I&#8217;m just going to focus on the one line with the URLRequest.  In order to traverse an XML tree you need start with the base.  Your XML var (in our case it&#8217;s called <strong>xml</strong>) points to that base (in this case the base is <strong>gallery</strong>).  So when we want to access the attribute <strong>dir</strong> in the tag <strong>gallery</strong>, we need to type <strong>xml.@dir</strong> and this will return <em>&#8220;//url/Photos/&#8221;</em>.  The &#8216;@&#8217; symbol denotes that it&#8217;s an attribute and not an element (tag).</p>
<p>Getting the file name is just one step further.  <strong>currentImg</strong> is a Number variable that stores which image we are on.  Thinking of our XML var as something similar to a bunch of nested arrays we can see how you might access a specific file name with <strong>xml.img[currentImg].@file</strong> This says we want the file attribute in the [currentImg] (first second so forth) img element which is in our base element.  There are quite a few ways of finding what you need in an XML doc and you can learn more about them<a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00000129.html"> here</a>.</p>
<p>In the second function we are displaying the text from within our XML img element.  Here we aren&#8217;t accessing any attributes or anything, this is where we get the content between the open &lt;img&gt; and close &lt;/img&gt; tags.</p>
<p>Finally we have the arrow MouseEvent handlers:</p>
<div class="dean_ch" style="white-space: wrap;">protected <span class="kw2">function</span> arrowOut<span class="br0">&#40;</span>event:MouseEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">MovieClip</span><span class="br0">&#40;</span>event.<span class="me1">currentTarget</span><span class="br0">&#41;</span>.<span class="kw3">gotoAndStop</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p>protected <span class="kw2">function</span> arrowOver<span class="br0">&#40;</span>event:MouseEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">MovieClip</span><span class="br0">&#40;</span>event.<span class="me1">currentTarget</span><span class="br0">&#41;</span>.<span class="kw3">gotoAndStop</span><span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p>protected <span class="kw2">function</span> nextImg<span class="br0">&#40;</span>event:MouseEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; loader.<span class="me1">unload</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentImg = <span class="br0">&#40;</span>currentImg &lt; lastImg<span class="br0">&#41;</span>? currentImg + <span class="nu0">1</span> : <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; loadImg<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p>protected <span class="kw2">function</span> prevImg<span class="br0">&#40;</span>event:MouseEvent<span class="br0">&#41;</span>:<span class="kw3">void</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; loader.<span class="me1">unload</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentImg = <span class="br0">&#40;</span>currentImg &gt; <span class="nu0">0</span><span class="br0">&#41;</span>? currentImg &#8211; <span class="nu0">1</span> : lastImg;<br />
&nbsp; &nbsp; &nbsp; &nbsp; loadImg<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>Once again I&#8217;m using the less obvious form of the if..else statement.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw1">if</span><span class="br0">&#40;</span>num&gt;<span class="nu0">5</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; num = <span class="nu0">5</span>;<br />
<span class="br0">&#125;</span><span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; num = <span class="nu0">0</span>;<br />
<span class="br0">&#125;</span><br />
<span class="co1">//OR, THIS NEXT PART DOES THE SAME THING</span><br />
num = <span class="br0">&#40;</span>num&gt;<span class="nu0">5</span><span class="br0">&#41;</span>? <span class="nu0">5</span> : <span class="nu0">0</span>;</div>
<p>Well that&#8217;s about it for this level of a gallery.  You can make galleries look really nice with fade transitions between images, small loading animations for larger images, scrollable thumbnail selection menu&#8230;  etc.</p>
<p>Here is a downloadable source of my example file (images not included&#8230; get them <a href="http://www.stockvault.net/">here</a>): <a href="http://www.clickpopmedia.com/wp-content/uploads/2008/05/xmlgallery.zip">XMLGallery.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clickpopmedia.com/2008/05/14/creating-an-xml-gallery-with-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>

