<?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>myXMLProject</title>
	<atom:link href="http://www.myxmlproject.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.myxmlproject.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 05 Jun 2011 23:58:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flash Photo Gallery Part 3:   Build a MovieClip to Scroll Thumbnails</title>
		<link>http://www.myxmlproject.com/flash-photo-gallery-step-3-build-a-movieclip-to-scroll-thumbnails/</link>
		<comments>http://www.myxmlproject.com/flash-photo-gallery-step-3-build-a-movieclip-to-scroll-thumbnails/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 21:20:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.myxmlproject.com/?p=182</guid>
		<description><![CDATA[This is a 3 part series of articles:

Part 1:  Use ActionScript to read an XML file
Part 2:  Build a Photo Detail View and Slide Show
Part 3:  Build a Scrollable MovieClip

Demo of the SimplePhotoBox Gallery

The Scrollable MovieClip contains 2 main parts:

ThumbBase Class - Container for the ThumbScroll (scrollable thumbnail photo buttons), and the [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a 3 part series of articles:</p>
<ul>
<li><a href="http://www.myxmlproject.com/read-xml-file-in-flash/">Part 1:  Use ActionScript to read an XML file</a></li>
<li><a href="http://www.myxmlproject.com/build-a-flash-slideshow/">Part 2:  Build a Photo Detail View and Slide Show</a></li>
<li><a href="#">Part 3:  Build a Scrollable MovieClip</a></em></li>
</ul>
<p><a href="http://www.myxmlproject.com/gallery/bigsur/">Demo of the SimplePhotoBox Gallery</a><br />
<span id="more-182"></span><br />
The Scrollable MovieClip contains 2 main parts:</p>
<ol>
<li><strong>ThumbBase Class </strong>- Container for the ThumbScroll (scrollable thumbnail photo buttons), and the ScrollPrevious, ScrollNext buttons.  ThumbBase controls the visible portion of the ThumbScroll object.</li>
<li><strong>ThumbScroll Class </strong>holds the individual thumbnails.  It extends beyond the borders of the visible area.</li>
</ol>
<p>Here&#8217;s how FlashPhotoGallery creates ThumbBase and ThumbScroll.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">thumbBase = <span style="color: #000000; font-weight: bold;">new</span> ThumbBase<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
thumbBase.<span style="color: #006600;">x</span> = thumbBaseX;
thumbBase.<span style="color: #006600;">y</span> = thumbBaseY;
addChild<span style="color: #66cc66;">&#40;</span>thumbBase<span style="color: #66cc66;">&#41;</span>;
&nbsp;
thumbScroll = <span style="color: #000000; font-weight: bold;">new</span> ThumbScroll<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
thumbScroll.<span style="color: #006600;">x</span> = thumbScroll.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">0</span>;
thumbScroll.<span style="color: #006600;">scrollRect</span> = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, canvasW, canvasH<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> maxWidth:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
maxWidth = createThumbs<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
selectedItem = thumbs<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
thumbBase.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>thumbScroll<span style="color: #66cc66;">&#41;</span>;
thumbBase.<span style="color: #006600;">setScroll</span><span style="color: #66cc66;">&#40;</span>thumbScroll<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><strong>THUMBSCROLL CLASS</strong><br />
ThumbScroll provides a container to place the thumbnails.  Since the thumbnails may go beyond the viewable screen space, ThumbScroll handles positioning of visible thumbnails.  The scrollRect property of the movieclip defines this section of the ThumbScroll area that is visible.</p>
<p>The ThumbScroll Class is defined as a movie clip within the library.  Here&#8217;s how to define the ThumbScroll Movie Clip:</p>
<ul>
<li>Right-mouse click on the ThumbScroll movie clip in the library and select Properties.</li>
<li><strong>Class: ThumbScroll</strong></li>
<li><strong>Base Class:  fpg.ThumbScroll</strong></li>
</ul>
<p>This links the ThumbScroll with the fpg package.</p>
<p>When the mouse is over the scroll buttons, the <strong>ThumbScroll</strong> time line starts at frame 1 and continues looping until the scrollingNext and scrollingPrevious.</p>
<p>Here&#8217;s how to setup the timeline for scrolling:</p>
<ul>
<li>Select Frame 1, and bring up the action window.</li>
<li>Here&#8217;s the code to add into the action window:<br />
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>scrollingNext <span style="color: #66cc66;">||</span> scrollingPrevious<span style="color: #66cc66;">&#41;</span>
   <span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">else</span>
   <span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

</li>
<li>Select Frame 10 and add this code:  gotoAndPlay(1);
</li>
</ul>
<p>Each time a frame is entered, the event handler <strong>onEnterFrame</strong> is called and the ThumbScroll window changes vertical position.  Here&#8217;s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onEnterFrame</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> rect:Rectangle = scrollRect;
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>scrollingNext <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">!</span>isScrollAtBottom<span style="color: #66cc66;">&#40;</span>rect.<span style="color: #006600;">y</span> + dy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
		rect.<span style="color: #006600;">y</span> += dy;
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>scrollingPrevious <span style="color: #66cc66;">&amp;&amp;</span> rect.<span style="color: #006600;">y</span> <span style="color: #66cc66;">&gt;</span> dy<span style="color: #66cc66;">&#41;</span>
		rect.<span style="color: #006600;">y</span> -= dy;
&nbsp;
	scrollRect = rect;				
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.myxmlproject.com/flash-photo-gallery-step-3-build-a-movieclip-to-scroll-thumbnails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Build a Flash Photo Gallery Part 2:  Build a Photo Detail View and Slide Show</title>
		<link>http://www.myxmlproject.com/build-a-flash-slideshow/</link>
		<comments>http://www.myxmlproject.com/build-a-flash-slideshow/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 22:39:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.myxmlproject.com/?p=142</guid>
		<description><![CDATA[This is a 2 part series of articles:

Part 1:  Use ActionScript to read an XML file
Part 2:  Build a Photo Detail View and Slide Show
Part 3:  Build a Scrollable MovieClip


The PhotoDetail Class:  displays an enlarged view of the photo when a thumbnail is selected.
Slide Show Functionality within the PhotoDetail Class.  [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a 2 part series of articles:</p>
<ul>
<li><a href="http://www.myxmlproject.com/read-xml-file-in-flash/">Part 1:  Use ActionScript to read an XML file</a></li>
<li><a href="http://www.myxmlproject.com/build-a-flash-slideshow/">Part 2:  Build a Photo Detail View and Slide Show</a></li>
<li><a href="http://www.myxmlproject.com/flash-photo-gallery-step-3-build-a-movieclip-to-scroll-thumbnails/">Part 3:  Build a Scrollable MovieClip</a></em></li>
</ul>
<ol>
<li><strong>The PhotoDetail Class</strong>:  displays an enlarged view of the photo when a thumbnail is selected.</li>
<li><strong>Slide Show Functionality within the PhotoDetail Class</strong>.  One photo gradually dissolves into the next.</li>
<li><strong>Slide Show Intervals</strong>:  Allow for automatic operation of the slideshow with a timer interval of 5 seconds.</li>
</ol>
<p><span id="more-142"></span></p>
<p><a href="http://www.myxmlproject.com/gallery/bigsur/"  class="uline" target="blank">Demo of the SimplePhotoBox Gallery</a></p>
<ol>
<li><strong>PHOTODETAIL CLASS</strong><br />
PhotoDetail provides an enlarged view of the photo.  The sideshow is active when the PhotoDetail object is created.  Function <strong>displayPicture</strong> gets everything started:  Takes the photo file name from the thumbnail array, loads the image file from the server and calls <strong>imgLoaded </strong>when complete.<br/></p>
<p>The PhotoDetail Class is defined as a movie clip within the library.  Here&#8217;s how to define the PhotoDetail Movie Clip:</p>
<ul>
<li>Right-mouse click on the PhotoDetail movie clip in the library and select Properties.</li>
<li><strong>Class: PhotoDetail</strong></li>
<li><strong>Base Class:  fpg.PhotoDetail</strong></li>
</ul>
<p>This links the PhotoDetail movie clip within the library with the PhotoDetail Class in the fpg package.</p>
<p><strong>imgLoaded </strong><br />
Each photo can have a different set of dimensions.  Landscape photos are maximized for width and portrait photos are maximized for height.  the <strong>currentChild</strong> object holds the photo.  drawBg uses graphics routines to create a white border around the picture.</p>
<p>GoToAndPlay(2) runs a timeline that gradually fades the old photo and displays the new photo.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
<span style="color: #808080; font-style: italic;">/******************************
* PhotoDetail class:   Extends MovieClip to act to display the selected photo. */</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PhotoDetail <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span> 
<span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">//***************************</span>
<span style="color: #808080; font-style: italic;">// Properties:</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>				:<span style="color: #0066CC;">Object</span>;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">leftMargin</span>			:<span style="color: #0066CC;">Number</span>;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> topMargin			:<span style="color: #0066CC;">Number</span>;	
protected <span style="color: #000000; font-weight: bold;">var</span> pictLdr			:Loader;
protected <span style="color: #000000; font-weight: bold;">var</span> pictURL			:<span style="color: #0066CC;">String</span>;
protected <span style="color: #000000; font-weight: bold;">var</span> bgColor			:uint = 0x000000;
protected <span style="color: #000000; font-weight: bold;">var</span> frameColor		             :uint = 0xffffff;				
protected <span style="color: #000000; font-weight: bold;">var</span> currentChild		             :<span style="color: #66cc66;">*</span>;
protected <span style="color: #000000; font-weight: bold;">var</span> canvasW			:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">925</span>;
protected <span style="color: #000000; font-weight: bold;">var</span> canvasH			:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">510</span>;
protected <span style="color: #000000; font-weight: bold;">var</span> wait				:Wait;
protected <span style="color: #000000; font-weight: bold;">var</span> flashPhotoGallery	             :FlashPhotoGallery;
&nbsp;
<span style="color: #808080; font-style: italic;">//***************************</span>
<span style="color: #808080; font-style: italic;">// Public methods:</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> displayPicture<span style="color: #66cc66;">&#40;</span>o:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	wait.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// Save values</span>
	<span style="color: #0066CC;">data</span> = o;
&nbsp;
	pictLdr = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	pictURL= <span style="color: #0066CC;">data</span>.<span style="color: #66cc66;">@</span>img;
	pictLdr.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>pictURL<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	pictLdr.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, imgLoaded<span style="color: #66cc66;">&#41;</span>;	
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//***************************</span>
<span style="color: #808080; font-style: italic;">// Event handlers:</span>
protected <span style="color: #000000; font-weight: bold;">function</span> imgLoaded<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>	
	alpha = <span style="color: #cc66cc;">0</span>;
	graphics.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>currentChild <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span>
		removeChild<span style="color: #66cc66;">&#40;</span>currentChild<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	currentChild = pictLdr.<span style="color: #006600;">content</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// Scale</span>
	<span style="color: #000000; font-weight: bold;">var</span> pictWidth: uint = currentChild.<span style="color: #0066CC;">width</span>;
	<span style="color: #000000; font-weight: bold;">var</span> pictHeight: uint = currentChild.<span style="color: #0066CC;">height</span>;
	<span style="color: #000000; font-weight: bold;">var</span> pictScale: <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">1</span>;
&nbsp;
	pictScale = <span style="color: #66cc66;">&#40;</span>canvasH+<span style="color: #0066CC;">leftMargin</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>pictHeight;
&nbsp;
	currentChild.<span style="color: #006600;">scaleX</span> = currentChild.<span style="color: #006600;">scaleY</span> = pictScale;
	<span style="color: #000000; font-weight: bold;">var</span> newLeftMargin: <span style="color: #0066CC;">Number</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>canvasW-<span style="color: #0066CC;">leftMargin</span><span style="color: #66cc66;">&#41;</span> -<span style="color: #66cc66;">&#40;</span>pictWidth <span style="color: #66cc66;">*</span> pictScale<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>;
	x = newLeftMargin <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span> ? <span style="color: #66cc66;">&#40;</span>newLeftMargin + <span style="color: #0066CC;">leftMargin</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">leftMargin</span>;			
	y = topMargin;
&nbsp;
	<span style="color: #808080; font-style: italic;">// Add a Clipping Region</span>
	<span style="color: #000000; font-weight: bold;">var</span> square:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	square.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0x000000, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
	square.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, canvasW-<span style="color: #cc66cc;">25</span>, canvasH+<span style="color: #0066CC;">leftMargin</span><span style="color: #66cc66;">&#41;</span>;
	addChild<span style="color: #66cc66;">&#40;</span>square<span style="color: #66cc66;">&#41;</span>;
	currentChild.<span style="color: #006600;">mask</span> = square;
	<span style="color: #808080; font-style: italic;">// End of Clipping Region</span>
&nbsp;
	wait.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	addChild<span style="color: #66cc66;">&#40;</span>pictLdr.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	drawBg<span style="color: #66cc66;">&#40;</span>pictLdr.<span style="color: #006600;">content</span>.<span style="color: #0066CC;">height</span>, pictLdr.<span style="color: #006600;">content</span>.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">gotoAndPlay</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
<li><strong>SLIDE SHOW</strong><br />
The sideshow is active when the PhotoDetail object is created.  There are 2 main parts to the slideshow functionality:  the dissolve transition and the interval timing.</p>
<p>PhotoDetail Class is a movie clip defined within the Flash library. Each time a new picture is displayed, the old movie clip is removed and a new movie clip is displayed by gradually increasing the alpha.  A timeline within the movie clip starts with the call gotoAndPlay(2).  Starting at frame 2 in the timeline, the movie clip plays until it encounters stop().   </p>
<p>Here&#8217;s how to add actions to the timeline.  Bring up the PhotoDetail movie Clip on the stage.  Click in frame 1.  Bring up the actions window (Window -> Actions).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">Frame <span style="color: #cc66cc;">1</span> Action:
     alpha = <span style="color: #cc66cc;">1</span>;
     <span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
Frame <span style="color: #cc66cc;">40</span> Action:
     <span style="color: #0066CC;">gotoAndPlay</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>So far, I haven&#8217;t described where the alpha changes.  The alpha changes each time a new frame is entered.  The PhotoDetail constructor calls: addEventListener(Event.ENTER_FRAME,onEnterFrame).  onEnterFrame changes the alpha by +.025.  Across 40 frames this makes the alpha = 1.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> PhotoDetail<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
             <span style="color: #808080; font-style: italic;">// Construct!</span>
	buttonMode = <span style="color: #000000; font-weight: bold;">true</span>;			
&nbsp;
	<span style="color: #808080; font-style: italic;">// Event Handlers</span>
	addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>,<span style="color: #0066CC;">onEnterFrame</span><span style="color: #66cc66;">&#41;</span>;
	addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, detailClickHandler<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onEnterFrame</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>currentFrame <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>currentFrame == <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">alpha</span> += .025;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
<li><strong>SLIDE SHOW INTERVALS</strong>
<p>SimplePhotoBox Class, the top most movie clip holds all of the other movie clips, symbols and buttons.  SimplePhotoClass controls the slide show interval.  <strong>intervalDuration</strong> is defined as 5000 miliseconds.  Each photo should be visible for 5 seconds.  Every 5 seconds slideShowNext is called to bring up the next photo in the list.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> nextSlide<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> currentPhoto: <span style="color: #0066CC;">Number</span> = selectedItem.<span style="color: #0066CC;">index</span> + <span style="color: #cc66cc;">1</span>;		
	<span style="color: #0066CC;">clearInterval</span><span style="color: #66cc66;">&#40;</span>intervalId<span style="color: #66cc66;">&#41;</span>;
	intervalId = <span style="color: #0066CC;">setInterval</span><span style="color: #66cc66;">&#40;</span>slideShowNext, intervalDuration<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>currentPhoto <span style="color: #66cc66;">&gt;</span>= thumbs.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>
		currentPhoto = <span style="color: #cc66cc;">0</span>;
	displayPicture<span style="color: #66cc66;">&#40;</span>thumbs<span style="color: #66cc66;">&#91;</span>currentPhoto<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.myxmlproject.com/build-a-flash-slideshow/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Build a Flash Photo Gallery Part 1: Read XML file in Flash</title>
		<link>http://www.myxmlproject.com/read-xml-file-in-flash/</link>
		<comments>http://www.myxmlproject.com/read-xml-file-in-flash/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 17:37:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.myxmlproject.com/?p=64</guid>
		<description><![CDATA[Want to create a photo album for your website?  This tutorial uses ActionScript to create a Flash photo album.  The photos are stored externally and neatly organized using XML.  Support for XML is one nice feature of ActionScript.  No need to use DOM methods to traverse the XML file.  Directly [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Want to create a photo album for your website?  This tutorial uses ActionScript to create a Flash photo album.  The photos are stored externally and neatly organized using XML.  Support for XML is one nice feature of ActionScript.  No need to use DOM methods to traverse the XML file.  Directly access XML content through tag names and attributes.</strong></p>
<p><em>This is a 1 part series of articles:</p>
<ul>
<li><a href="http://www.myxmlproject.com/read-xml-file-in-flash/">Part 1:  Use ActionScript to read an XML file</a></li>
<li><a href="http://www.myxmlproject.com/build-a-flash-slideshow/">Part 2:  Build a Photo Detail View and Slide Show</a></li>
<li><a href="http://www.myxmlproject.com/flash-photo-gallery-step-3-build-a-movieclip-to-scroll-thumbnails/">Part 3:  Build a Scrollable MovieClip</a></em></li>
</ul>
<p><strong>This tutorial describes how to use ActionScript to read an XML file and create thumbnails.  SimplePhotoBox is a Flash application that reads XML and image files exported from Picasa and displays a professional looking Photo Gallery and Slide Show.</strong></p>
<p><a href="http://www.myxmlproject.com/gallery/bigsur/" onclick='javascript: pageTracker._trackVisit (''/gallery/bigsur/");'  class="uline" target="blank">Demo of the SimplePhotoBox Gallery</a></p>
<p><span id="more-64"></span></p>
<p>SimplePhotoBox parses the photos.xml file:  each <strong>image</strong> tag contains the location of an image file and a 250&#215;250 thumbnail file. The Flash movieclip parses photos.xml, then reads each thumbnail and displays the thumbnail on screen.  </p>
<p>SimplePhotoBox consists of 4 basic parts: </p>
<ol>
<li><strong>FlashPhotoGallery</strong> &#8211; the movie clip that is a wrapper for the application</li>
<li><strong>ThumbBase and ThumbScroll</strong> &#8211; the scrollable thumbnail display area</li>
<li><strong>PhotoThumb1&#8230;n</strong> &#8211; individual, clickable thumbnail images of each photo.</li>
<li><strong>PhotoDetail</strong> &#8211; shows a single photo covering the display area.</li>
</ol>
<p><a href="http://www.myxmlproject.com/wp-content/uploads/2009/12/FlashPhotoGalleryGraph2.gif"><img src="http://www.myxmlproject.com/wp-content/uploads/2009/12/FlashPhotoGalleryGraph2-300x220.gif" alt="FlashPhotoGalleryGraph" title="FlashPhotoGalleryGraph" width="300" height="220" class="alignnone size-medium wp-image-113" /></a></p>
<p>All of the photos reside in an images directory and are organized in the file photos.xml.   Here&#8217;s what the photos.xml file looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;album<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">flag</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;albumCaption</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Big Sur&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/albumCaption<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;big_sur_144.jpg / Point Lobos, Andrew Molera, Julia Pfeiffer&quot;</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/big_sur_144.jpg&quot;</span> <span style="color: #000066;">thmb</span>=<span style="color: #ff0000;">&quot;thumbnails/big_sur_144.jpg&quot;</span> <span style="color: #000066;">downloadimg</span>=<span style="color: #ff0000;">&quot;images/big_sur_144.jpg&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;not available...&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;JPG&quot;</span>  <span style="color: #000066;">dt</span>=<span style="color: #ff0000;">&quot;April 2010&quot;</span>  <span style="color: #000066;">thumbw</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">thumbh</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">tags</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>big_sur_144.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;big_sur_138.jpg / Point Lobos, Andrew Molera, Julia Pfeiffer&quot;</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/big_sur_138.jpg&quot;</span> <span style="color: #000066;">thmb</span>=<span style="color: #ff0000;">&quot;thumbnails/big_sur_138.jpg&quot;</span> <span style="color: #000066;">downloadimg</span>=<span style="color: #ff0000;">&quot;images/big_sur_138.jpg&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;not available...&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;JPG&quot;</span>  <span style="color: #000066;">dt</span>=<span style="color: #ff0000;">&quot;April 2010&quot;</span>  <span style="color: #000066;">thumbw</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">thumbh</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">tags</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> big_sur_138.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;big_sur_141.jpg / Point Lobos, Andrew Molera, Julia Pfeiffer&quot;</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/big_sur_141.jpg&quot;</span> <span style="color: #000066;">thmb</span>=<span style="color: #ff0000;">&quot;thumbnails/big_sur_141.jpg&quot;</span> <span style="color: #000066;">downloadimg</span>=<span style="color: #ff0000;">&quot;images/big_sur_141.jpg&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;not available...&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;JPG&quot;</span>  <span style="color: #000066;">dt</span>=<span style="color: #ff0000;">&quot;April 2010&quot;</span>  <span style="color: #000066;">thumbw</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">thumbh</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">tags</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>big_sur_141.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;big_sur_182.jpg / Point Lobos, Andrew Molera, Julia Pfeiffer&quot;</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/big_sur_182.jpg&quot;</span> <span style="color: #000066;">thmb</span>=<span style="color: #ff0000;">&quot;thumbnails/big_sur_182.jpg&quot;</span> <span style="color: #000066;">downloadimg</span>=<span style="color: #ff0000;">&quot;images/big_sur_182.jpg&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;not available...&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;JPG&quot;</span>  <span style="color: #000066;">dt</span>=<span style="color: #ff0000;">&quot;April 2010&quot;</span>  <span style="color: #000066;">thumbw</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">thumbh</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">tags</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> big_sur_182.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/album<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>1.  <strong>Open the xml file:</strong></p>
<p><strong>URLLoader</strong> loads the XML file into this container class  .  Actionscript restriction: load files must be from the same domain as the flash application (SWF).  The event handler<strong> onDataHandler</strong> is set to trigger when loading is complete.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FlashPhotoGallery <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span> 
<span style="color: #66cc66;">&#123;</span> 
<span style="color: #808080; font-style: italic;">//***************************</span>
<span style="color: #808080; font-style: italic;">// HTTP: </span>
protected <span style="color: #000000; font-weight: bold;">var</span> loaderURLLoader; 
protected <span style="color: #000000; font-weight: bold;">var</span> photosXML :<span style="color: #0066CC;">XML</span>; 
protected <span style="color: #000000; font-weight: bold;">var</span> photosPath :<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;photos.xml&quot;</span>; 
protected <span style="color: #000000; font-weight: bold;">var</span> thumbBase :ThumbBase; 
protected <span style="color: #000000; font-weight: bold;">var</span> thumbScroll :ThumbScroll; 
protected <span style="color: #000000; font-weight: bold;">var</span> thumbs :<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
protected <span style="color: #000000; font-weight: bold;">var</span> photoDetail : PhotoDetail; 
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> FlashPhotoGallery<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
<span style="color: #66cc66;">&#123;</span> 
   <span style="color: #808080; font-style: italic;">// Load data! </span>
   loader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
   loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>photosPath<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; 
   loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onDataHandler<span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>2.  <strong>Create the Thumbnails:</strong>  </p>
<p>The function <strong>onDataHandler()</strong> is triggered when photos.xml has been loaded. Next step is to create a new XML object to hold the data and create thumbnails.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">protected <span style="color: #000000; font-weight: bold;">function</span> onDataHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
<span style="color: #66cc66;">&#123;</span> 
   photosXML = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span>loader.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>; 
   thumbsTotal = photosXML.<span style="color: #006600;">image</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
   galleryTitle.<span style="color: #0066CC;">text</span> = photosXML.<span style="color: #006600;">albumCaption</span>.<span style="color: #66cc66;">@</span>title; 
   createThumbs<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span> 
protected <span style="color: #000000; font-weight: bold;">function</span> createThumbs<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
<span style="color: #66cc66;">&#123;</span> 
   <span style="color: #808080; font-style: italic;">// THUMBNAILS (Layout the photo thumbnails) </span>
   <span style="color: #000000; font-weight: bold;">var</span> maxWidth:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>; 
   <span style="color: #000000; font-weight: bold;">var</span> maxHeight:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>; 
   <span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;">0</span>; 
   <span style="color: #b1b100;">for</span> each<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> thisImage:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> photosXML.<span style="color: #006600;">image</span> <span style="color: #66cc66;">&#41;</span> 
   <span style="color: #66cc66;">&#123;</span> 
      <span style="color: #000000; font-weight: bold;">var</span> deltaX:<span style="color: #0066CC;">Number</span> = i - <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>i <span style="color: #66cc66;">/</span> thumbsPerRow<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> thumbsPerRow; 
      <span style="color: #000000; font-weight: bold;">var</span> deltaY:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span>i <span style="color: #66cc66;">/</span> thumbsPerRow<span style="color: #66cc66;">&#41;</span>; 
      <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">XML</span> = thisImage; 
      thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">new</span> PhotoThumbnail<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
      thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">setData</span><span style="color: #66cc66;">&#40;</span>i, <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;  
      <span style="color: #000000; font-weight: bold;">var</span> thumbw:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">data</span>.<span style="color: #66cc66;">@</span>thumbw; 
      <span style="color: #000000; font-weight: bold;">var</span> thumbh:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">data</span>.<span style="color: #66cc66;">@</span>thumbh; 
      thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">x</span> = deltaX <span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>thumbw + thumbXSpacing<span style="color: #66cc66;">&#41;</span>;
      thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">y</span> = deltaY <span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>thumbh + thumbYSpacing<span style="color: #66cc66;">&#41;</span>; 
      maxWidth = thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">x</span> + thumbw+ thumbXSpacing; 
      maxHeight = thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">y</span> + thumbh+ thumbYSpacing; 
      thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, thumbClickHandler<span style="color: #66cc66;">&#41;</span>; 
      thumbScroll.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>thumbs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>; 
      i++; 
   <span style="color: #66cc66;">&#125;</span> 
   thumbScroll.<span style="color: #006600;">maxHeight</span> = maxHeight; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</p>
<p>The <strong>for each </strong>statement loops each image tag using the variable: <strong>photosXML.image.</strong>.   <strong>data.@thumbw</strong> refers to the image attribute thumbw.  The PhotoThumbnail object controls the image display and mouse click event.</p>
<p>Clicking on a thumbnail, expands the photo.  Here&#8217;s how this is done.  Define the event handler for each thumbnail using the call <strong>addEventListener</strong> (see the <strong>createThumbs</strong> function above).  Next, define the event handler that takes action when the mouse click occurs.  Here&#8217;s an example of an event handler:
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">protected <span style="color: #000000; font-weight: bold;">function</span> thumbClickHandler<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>   			
      startSlideshow<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
      displayPicture<span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>;		
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><a href="http://www.myxmlproject.com/build-a-flash-slideshow/">View Step 2:  Detail View and Slide Show</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.myxmlproject.com/read-xml-file-in-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Customize RSS Feeds with PHP</title>
		<link>http://www.myxmlproject.com/customize-rss-feeds-with-php/</link>
		<comments>http://www.myxmlproject.com/customize-rss-feeds-with-php/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 23:15:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.myxmlproject.com/?p=24</guid>
		<description><![CDATA[Customize the display of your RSS feed using HTML and PHP.  Starting with PHP version 5, SimpleXML loads, and parses an XML document. SimpleXML makes it easier to get access to xml content.  Take a look at this simple example.  

PHP provides a nice solution for inserting RSS feeds into an HTML [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Customize the display of your RSS feed using HTML and PHP.  Starting with PHP version 5, SimpleXML loads, and parses an XML document. SimpleXML makes it easier to get access to xml content.  Take a look at this simple example.</strong>  </p>
<p><span id="more-24"></span><br />
PHP provides a nice solution for inserting RSS feeds into an HTML document.  Unlike previous XML implementations, SimpleXML uses the XML tag names as variables.  <a href="http://cyber.law.harvard.edu/rss/rss.html" target="blank" class="uline">If you need a refresher on the RSS 2.0 specification take a look at this site.</a></p>
<p>Here is the PHP code:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></span>
<span style="color: #009900;">if <span style="color: #66cc66;">&#40;</span>isset<span style="color: #66cc66;">&#40;</span>$_GET<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'category'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></span>
<span style="color: #009900;">  $rssfeed_category = <span style="color: #66cc66;">&#40;</span>get_magic_quotes_gpc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> ? $_GET<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'category'</span><span style="color: #66cc66;">&#93;</span> : addslashes<span style="color: #66cc66;">&#40;</span>$_GET<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'category'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">else</span>
<span style="color: #009900;">  $rssfeed_category = <span style="color: #ff0000;">'http://rss.news.yahoo.com/rss/topstories'</span>;</span>
<span style="color: #009900;">  libxml_use_internal_errors<span style="color: #66cc66;">&#40;</span>true<span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #009900;">  if <span style="color: #66cc66;">&#40;</span>$rssfeed = simplexml_load_file<span style="color: #66cc66;">&#40;</span>$rssfeed_category<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">     foreach <span style="color: #66cc66;">&#40;</span>$rssfeed-<span style="color: #000000; font-weight: bold;">&gt;</span></span>channel as $channel) {
        echo '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h2<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;' . $channel-&gt;</span></span>link . '&quot;&gt;' .
				$channel-&gt;title . '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/h2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>';
        echo '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>' . $channel-&gt;description . '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>';
&nbsp;
        foreach ($channel-&gt;item as $item) {
           echo '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;rssItem&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>';
           echo '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>';
           echo '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;' . $item-&gt;</span></span>link . '&quot; class=&quot;rssLink&quot;&gt;';
           echo $item-&gt;title . '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>';
           echo $item-&gt;description . '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>';
           echo '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>';
           echo '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>';
        }
   }
}
else echo 'RSS feed could not be read. ' . $rssfeed_category . '<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>';
?&gt;</pre></div></div>

<p>Tips to making this work:</p>
<ul>
<li>Reserved HTML characters such as ampersand (&amp;) and greater than(&gt;) can cause problems if they appear as ordinary text in an XML document. The browser will mistake these reserved characters for markup.  Use the php function <strong>htmlentities</strong> to convert characters such as &amp; to &amp;amp; if this becomes a problem.</li>
<li>Many RSS feeds contain HTML markup for formatting purposes.  In this case, htmlentities is NOT recommened.  <a href="http://www.myxmlproject.com/projects/parserss/rsstest.php?category=http://www.news.ucdavis.edu/xml/getnews.php/rss/category/Environmental%20Sciences"  target="blank" class="uline">Here&#8217;s an example of using htmlentities with description text containing HTML markup.</a>
<li>Character encoding can also lead to display problems.  To ensure proper display of special characters, pay attention to the character encoding.  UTF-8 is the default character encoding for XML.  ISO-8859-1 is more commonly used in HMTL.  If you use UTF-8 encoding in the HTML document&#8217;s head section, the special characters should print correctly.

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;</pre></div></div>

</li>
<li>A file access warning from simplexml_load_file() may indicate a server warning.  Check the php.ini configuration option <strong>allow_url_fopen = On</strong>.  This will give the simplexml_load_file() function the ability to open the remote rss file.  However it will not be good for website security because it leads to PHP Remote File Include Hacks.</li>
<p> RELATED POSTS:</p>
<ul>
<li><a href="http://www.w3schools.com/PHP/func_string_htmlentities.asp" target="blank" >PHP htmlentities</a></li>
<li><a href="http://cyber.law.harvard.edu/rss/rss.html" target="blank" >RSS 2.0 Specification</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.myxmlproject.com/customize-rss-feeds-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML Transformation using Sarissa</title>
		<link>http://www.myxmlproject.com/xml-transformation-using-sarissa/</link>
		<comments>http://www.myxmlproject.com/xml-transformation-using-sarissa/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 16:24:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.myxmlproject.com/?p=4</guid>
		<description><![CDATA[Sarissa was developed to allow cross-browser support for manipulating XML files.  This is important for web pages accessing XML with JavaScript.  Firefox, IE and Safari implementations of JavaScript each handle XML files differently.  Sarissa is a set of downloadable JavaScript files that standardize XML manipulation.
PHOTO GALLERY USING XML
Several popular web based photo applications (Picasa [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Sarissa was developed to allow cross-browser support for manipulating XML files.  This is important for web pages accessing XML with JavaScript.  Firefox, IE and Safari implementations of JavaScript each handle XML files differently.  Sarissa is a set of downloadable JavaScript files that standardize XML manipulation.</strong></p>
<p><strong>PHOTO GALLERY USING XML</strong></p>
<p>Several popular web based photo applications (Picasa and JAlbum) have export options that can generate XML files along with photo images to create a photo album in a web page.  I have created a simple implementation that uses a similar approach.  Sarissa methods parse the file:  sherrypicsmenu.xml for image files and thumbnail files.  HTML code is inserted into the web page to display a thumbnail bar, and detail photo images.<br />
<span id="more-4"></span><br />
Here&#8217;s the XML file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;iso-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photogallery<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photo</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;buttonarmsxdcat.jpg&quot;</span> <span style="color: #000066;">image</span>=<span style="color: #ff0000;">&quot;armsxdcat.jpg&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photo</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;buttoncatbasket.jpg&quot;</span> <span style="color: #000066;">image</span>=<span style="color: #ff0000;">&quot;catbasket.jpg&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photo</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;buttondogsniff.jpg&quot;</span> <span style="color: #000066;">image</span>=<span style="color: #ff0000;">&quot;dogsniff.jpg&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photo</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;buttonyawndog.jpg&quot;</span> <span style="color: #000066;">image</span>=<span style="color: #ff0000;">&quot;yawndog.jpg&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photo</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;buttondbeagle.jpg&quot;</span> <span style="color: #000066;">image</span>=<span style="color: #ff0000;">&quot;dbeagle.jpg&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/photogallery<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>When the HTML page is loading, sherrypicsmenu.xml loads and is parsed.  Each photo tag from the xml file becomes a thumbnail with a link to the full sized image.</p>
<p>Here&#8217;s the JavaScript:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;&gt;
function initMenu(xmlFile) {
	var xml = Sarissa.getDomDocument();
	xml.async = false;
	xml.load(xmlFile);
&nbsp;
	var nodes = xml.documentElement.childNodes;
	var output = '';
&nbsp;
	for (var i = 0; i &lt;= nodes.length - 1; i++) {
		if (nodes.item(i).nodeType != Node.ELEMENT_NODE) continue;
&nbsp;
		output += '&lt;div id=&quot;photobutton&quot;&gt;';
		output += '&lt;a onclick=&quot;showpicture(\'../images/' + nodes.item(i).getAttribute('image') + '\')&quot;&gt;' +
			'&lt;img src=&quot;../images/' + nodes.item(i).getAttribute('target') + '&quot; /&gt;' + '&lt;/a&gt;&lt;br /&gt;';
		output += '&lt;/div&gt;';
&nbsp;
	}
	document.getElementById('photomenu').innerHTML = output;
    showpicture(&quot;../images/catbasket.jpg&quot;);
}
&nbsp;
window.onload = function() {
	initMenu('sherrypicsmenu.xml');
};
&lt;/script&gt;</pre></div></div>

<p><br/><br />
<br/><br />
RELATED POSTS:</p>
<ul>
<li><a href="http://sourceforge.net/projects/sarissa/" target="blank">Download Sarissa</a></li>
<li><a href="http://www.janbthomas.com/jansblog/photo-gallery-from-picasa-album/" target="blank">Export a Picasa Photo Album</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.myxmlproject.com/xml-transformation-using-sarissa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

