<?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>In Flagrante Delicto! &#187; AS3</title>
	<atom:link href="http://inflagrantedelicto.memoryspiral.com/tag/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://inflagrantedelicto.memoryspiral.com</link>
	<description>Joseph Labrecque: Senior Interactive Software Engineer - Artist - Author - Speaker - Adobe Education Leader - Adobe Community Professional</description>
	<lastBuildDate>Wed, 01 Feb 2012 15:09:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cookbook Draft is Half-Way Cooked</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2011/02/cookbook-draft-is-half-way-cooked/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2011/02/cookbook-draft-is-half-way-cooked/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 23:37:57 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Writing]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=3096</guid>
		<description><![CDATA[Yeah- I hit a pretty big milestone this week with the draft for my book on Android and Flash Platform development (the book is still untitled). I&#8217;ve submitted 5 chapters and am mid-way through a 6th. This actually places me &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2011/02/cookbook-draft-is-half-way-cooked/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_3106" class="wp-caption alignright" style="width: 310px"><img src="http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2011/02/halfway.png" alt="" title="Cookbook Draft" width="300" height="194" class="size-full wp-image-3106" /><p class="wp-caption-text">Cookbook Draft</p></div>Yeah- I hit a pretty big milestone this week with the draft for my book on <strong>Android </strong>and <strong>Flash Platform</strong> development (the book is still untitled). I&#8217;ve submitted 5 chapters and am mid-way through a 6th. This actually places me about a month and a half ahead of schedule, which is pretty darn good. 180 pages!!!</p>
<h3>Some Thoughts</h3>
<p>The process so far has been a lot like writing a bunch of small articles. I&#8217;ve handled it in a similar way to writing an album &#8211; one track/chapter at a time. Things are definitely overwhelming if you think about the entire work as a whole. If I didn&#8217;t segment my work like this, I&#8217;d probably stress about it so much that I&#8217;d get nothing done. It is often the half way point on a large project like this when you realize just how much things are actually coming together. Quite gratifying.</p>
<p>There are negatives to this entire process as well; I haven&#8217;t had a lot of free time for other projects, have had to pass up on some additional development opportunities through <strong>Fractured Vision Media</strong>, and it&#8217;s incredibly hard to balance family life along with everything I do. I&#8217;m fairly certain the positives will win out when this is all over though!</p>
<h3>Dropbox and Word</h3>
<p>I&#8217;ve been using the excellent <a href="http://db.tt/dXqvDB8"><strong>Dropbox</strong></a> service for revisions, automated backups, and simply sharing drafts across my studio machine and laptops. It has made document management absolutely painless and I highly recommend it to anyone involved in such a project. It has provided me with convenience and peace of mind!</p>
<p>On the dark side of things&#8230; I&#8217;ve been using <strong>Microsoft Word</strong> for all of my word processing and formatting. Enough said.</p>
<h3>Revisions</h3>
<p>After submitting the first couple of chapters, I had quite a few revisions to do dealing with formatting and even the structure of a lot of my recipes. It has turned out well though; as the recipes in their current form are quite simple to follow along with. I&#8217;ve actually used some of them for reference in my own development work! </p>
<p>While I&#8217;ve come quite far; I&#8217;m sure there will be many more revisions to come. These are just drafts and I have additional feedback from technical reviewers to work through. Really pleased with the foundation thus far.</p>
<h3>Outlook</h3>
<p>Like I mentioned above; things are looking good! My editor is pleased with the quality and timeliness of the draft chapters and we are in the process of defining a title, generating promotional copy, gathering technical reviewers, and should be announcing everything on the <strong><a href="http://www.packtpub.com/">Packt Publishing</a></strong> site in the next week or two!  </p>
<p>I&#8217;ll post another update once this has occurred so you can all <strong>pre-order</strong> ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2011/02/cookbook-draft-is-half-way-cooked/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 Google Analytics API</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2011/01/actionscript-3-google-analytics-api/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2011/01/actionscript-3-google-analytics-api/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 14:58:29 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Libraries]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=2931</guid>
		<description><![CDATA[Over on the Google Analytics weblog, they&#8217;ve posted about a new (official) AS3 library for GA! Apparently, the library is pretty robust, featuring; Metrics, Dimensions, Filters, Sequenced Pagination, and Data Views. I&#8217;ve dealt with Google Analytics and Flash in the &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2011/01/actionscript-3-google-analytics-api/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Over on the Google Analytics weblog, they&#8217;ve <a href="http://analytics.blogspot.com/2011/01/new-actionscript-3-library-for-api.html">posted</a> about a new (official) AS3 library for GA! Apparently, the library is pretty robust, featuring; Metrics, Dimensions, Filters, Sequenced Pagination, and Data Views.</p>
<div id="attachment_2932" class="wp-caption aligncenter" style="width: 310px"><a href="http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2011/01/gaas3.png"><img src="http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2011/01/gaas3-300x141.png" alt="" title="ActionScript 3 library for Google Analytics" width="300" height="141" class="size-medium wp-image-2932" /></a><p class="wp-caption-text">ActionScript 3 library for Google Analytics</p></div>
<p>I&#8217;ve dealt with Google Analytics and Flash in the past using the Google Analytics Tracking For Adobe Flash ActionScript 3 API which, from my experience, is still very useful. I even did a session on it at the FITC Unconference during Adobe MAX 2009.</p>
<p><a href="http://labs.denivip.ru/projects/asapiga">Grab the code</a> or <a href="http://labs.denivip.ru/projects/asapiga/wiki/QuickStart_Guide">check out a quickstart</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2011/01/actionscript-3-google-analytics-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CodeBass Article: AS3 Audio Libraries</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2010/11/codebass-article-as3-audio-libraries/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2010/11/codebass-article-as3-audio-libraries/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 17:30:56 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=2692</guid>
		<description><![CDATA[An article I had written on using a variety of ActionScript and Alchemy-based audio encoding libraries in Flash Player has been published over at CodeBass. Check it out and even play with the demo set from within your web browser. &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2010/11/codebass-article-as3-audio-libraries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_2694" class="wp-caption alignright" style="width: 216px"><a href="http://codebass.net/?p=35708"><img src="http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2010/11/audiotests-206x300.jpg" alt="" title="audiotests" width="206" height="300" class="size-medium wp-image-2694" /></a><p class="wp-caption-text">Audio Tests</p></div>
<p>An <a href="http://codebass.net/?p=35708">article</a> I had written on using a variety of ActionScript and Alchemy-based audio encoding libraries in Flash Player has been published over at CodeBass. </p>
<p>Check it out and even play with the demo set from within your web browser. Full source code and links to referenced AS3 libraries is also available.</p>
<p>Nice to finally get something up there!</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2010/11/codebass-article-as3-audio-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing Tweets with the TwitterString Class</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2010/01/parsing-tweets-with-the-twitterstring-class/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2010/01/parsing-tweets-with-the-twitterstring-class/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 19:13:59 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=1387</guid>
		<description><![CDATA[While building a little Twitter aggregator for an upcoming conference, I found myself in need of a set of methods to create hyperlinks from three distinct elements that can be included within a tweet; links, usernames, and hashtags. I was &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2010/01/parsing-tweets-with-the-twitterstring-class/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While building a little Twitter aggregator for an upcoming conference, I found myself in need of a set of methods to create hyperlinks from three distinct elements that can be included within a tweet; links, usernames, and hashtags.</p>
<p>I was able to find regular expressions to do all the heavy lifting from various sources on the Web and have created a class which pretty much does all the processing with one method call.  Here&#8217;s an example of the thing working, followed by example code, and the class itself.</p>
<h2>Example SWF</h2>
<p>
<object width="300" height="100">
<param name="movie" value="http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2010/01/TwitterStringDemo.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#000000"></param>
<param name="allowScriptAccess" value="always"></param>
<param name="allowFullScreen" value="true"></param>
<embed type="application/x-shockwave-flash" width="300" height="100" src="http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2010/01/TwitterStringDemo.swf" quality="high" bgcolor="#000000" wmode="window" menu="false" allowFullScreen="true" ></embed>
</object>
</p>
<hr/>
<h2>Example MXML</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td 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;s:Application</span> <span style="color: #000066;">xmlns:fx</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #009900;">			   <span style="color: #000066;">xmlns:s</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #009900;">			   <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> </span>
<span style="color: #009900;">			   <span style="color: #000066;">creationComplete</span>=<span style="color: #ff0000;">&quot;init()&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;300&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100&quot;</span> </span>
<span style="color: #009900;">			   <span style="color: #000066;">backgroundColor</span>=<span style="color: #ff0000;">&quot;#1E1E1E&quot;</span> <span style="color: #000066;">preloaderBaseColor</span>=<span style="color: #ff0000;">&quot;#989898&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">			import flashx.textLayout.elements.Configuration;</span>
<span style="color: #339933;">			import flashx.textLayout.elements.TextFlow;</span>
<span style="color: #339933;">			import flashx.textLayout.conversion.TextConverter;</span>
<span style="color: #339933;">			import flashx.textLayout.formats.TextLayoutFormat;</span>
<span style="color: #339933;">			import com.fracturedvisionmedia.utils.TwitterString;</span>
&nbsp;
<span style="color: #339933;">			private var myTxt:String = &quot;Everyone should follow @josephlabrecque (http://bit.ly/7NkqrB) - really cool stuff and super-informative insights! #Awesome #Super #LOL&quot;;</span>
&nbsp;
<span style="color: #339933;">			private function init():void {</span>
<span style="color: #339933;">				// Configure styling the TextFlow links to match richTxt</span>
<span style="color: #339933;">				var cfg:Configuration = TextFlow.defaultConfiguration;</span>
<span style="color: #339933;">				var normalTLF:TextLayoutFormat = new TextLayoutFormat(cfg.defaultLinkNormalFormat);</span>
<span style="color: #339933;">				normalTLF.color = 0xDCD9D9;</span>
<span style="color: #339933;">				cfg.defaultLinkNormalFormat = normalTLF;</span>
<span style="color: #339933;">				TextFlow.defaultConfiguration = cfg;</span>
&nbsp;
<span style="color: #339933;">				// Import tweet as HTML</span>
<span style="color: #339933;">				richTxt.textFlow = TextConverter.importToFlow(TwitterString.instance.parseTweet(myTxt), TextConverter.TEXT_FIELD_HTML_FORMAT);</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		]]&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:RichEditableText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;richTxt&quot;</span> <span style="color: #000066;">selectable</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">editable</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">color</span>=<span style="color: #ff0000;">&quot;#DCD9D9&quot;</span> <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<h2>TwitterString Class</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">fracturedvisionmedia</span>.<span style="color: #006600;">utils</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/**
	 * The TwitterString class assists with the parsing of a tweet to add hyperlinks 
	 * around Links, HashTags, and UserNames in a tweet.
	 * @author Joseph Labrecque
	 * v. 0.1.2
	 */</span> 
&nbsp;
	<span style="color: #0066CC;">public</span> final <span style="color: #000000; font-weight: bold;">class</span> TwitterString <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> _instance:TwitterString = <span style="color: #000000; font-weight: bold;">new</span> TwitterString<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> TwitterString<span style="color: #66cc66;">&#40;</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>_instance <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;TwitterString can only be accessed through TwitterString.instance&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> instance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:TwitterString <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _instance;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> parseTweet<span style="color: #66cc66;">&#40;</span>t:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> step1:<span style="color: #0066CC;">String</span> = parseHyperlinks<span style="color: #66cc66;">&#40;</span>t<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> step2:<span style="color: #0066CC;">String</span> = parseUsernames<span style="color: #66cc66;">&#40;</span>step1<span style="color: #66cc66;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">var</span> step3:<span style="color: #0066CC;">String</span> = parseHashtags<span style="color: #66cc66;">&#40;</span>step2<span style="color: #66cc66;">&#41;</span>
			<span style="color: #b1b100;">return</span> step3;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> parseUsernames<span style="color: #66cc66;">&#40;</span>t:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> result:<span style="color: #0066CC;">String</span> = t.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>^<span style="color: #66cc66;">|</span>\s<span style="color: #66cc66;">&#41;</span><span style="color: #808080; font-style: italic;">#(\w+)/g, &quot;$1#&lt;a href='http://search.twitter.com/search?q=$2' target='_blank'&gt;$2&lt;/a&gt;&quot;);</span>
			<span style="color: #b1b100;">return</span> result;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> parseHashtags<span style="color: #66cc66;">&#40;</span>t:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> result:<span style="color: #0066CC;">String</span> = t.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>^<span style="color: #66cc66;">|</span>\s<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">@</span><span style="color: #66cc66;">&#40;</span>\w+<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>g, <span style="color: #ff0000;">&quot;$1@&lt;a href='http://www.twitter.com/$2' target='_blank'&gt;$2&lt;/a&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> result;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> parseHyperlinks<span style="color: #66cc66;">&#40;</span>t:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> urlPattern:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;(((f|ht){1}tp://)[-a-zA-Z0-9@:%_<span style="color: #000099; font-weight: bold;">\+</span>.~#?&amp;//=]+)&quot;</span>, <span style="color: #ff0000;">&quot;g&quot;</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">var</span> result:<span style="color: #0066CC;">String</span> = t.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>urlPattern, <span style="color: #ff0000;">&quot;&lt;a href='$1' target='_blank'&gt;$1&lt;/a&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> result;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><a href='http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2010/02/TwitterString.as'> Download TwitterString</a></p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2010/01/parsing-tweets-with-the-twitterstring-class/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Display Application Version in your AIR App.</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2009/02/quick-tip-display-application-version-in-your-air-app/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2009/02/quick-tip-display-application-version-in-your-air-app/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 22:04:06 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=559</guid>
		<description><![CDATA[Just a quick tip for those looking to somehow display the AIR application version from the descriptor file. I&#8217;ve found it very helpful in troubleshooting is users can say EXACTLY what version of the app they are running. 1 2 &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2009/02/quick-tip-display-application-version-in-your-air-app/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Just a quick tip for those looking to somehow display the AIR application version from the descriptor file.  I&#8217;ve found it very helpful in troubleshooting is users can say EXACTLY what version of the app they are running.</p>
<p><img src="http://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2009/02/airver.png" alt="Application Version" title="Application Version" width="370" height="164" class="alignnone size-full wp-image-560" /></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getAppVersion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> appXml:<span style="color: #0066CC;">XML</span> = NativeApplication.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">applicationDescriptor</span>;
	<span style="color: #000000; font-weight: bold;">var</span> ns:Namespace = appXml.<span style="color: #006600;">namespace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> appVersion:<span style="color: #0066CC;">String</span> = appXml.<span style="color: #006600;">ns</span>::<span style="color: #0066CC;">version</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #b1b100;">return</span> appVersion;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2009/02/quick-tip-display-application-version-in-your-air-app/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Simple AS3 Slideshow Widget: Part 3</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-3/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-3/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 14:45:59 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=535</guid>
		<description><![CDATA[This is the final post in a three part tutorial detailing the creation of a Flash slideshow widget using ActionScript 3.0. Have a look over Part 1 and Part 2 before moving ahead. In this post, we are examining the &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is the final post in a three part tutorial detailing the creation of a Flash slideshow widget using ActionScript 3.0.  Have a look over <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-1/">Part 1</a> and <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-2/">Part 2</a> before moving ahead.</p>
<p>In this post, we are examining the two methods which actually handle image loading and display within our module.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> switchImage<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:TimerEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	imageBitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
	imageBitmap.<span style="color: #006600;">bitmapData</span> = imageBitmapData;
	imageBitmap.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">1</span>;
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>currentImage <span style="color: #66cc66;">&lt;</span> imageArray.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		currentImage++;
	<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
		currentImage = <span style="color: #cc66cc;">0</span>;
	<span style="color: #66cc66;">&#125;</span>
	urlRequ.<span style="color: #0066CC;">url</span> = appPath + <span style="color: #ff0000;">&quot;path/to/images/&quot;</span> + imageArray<span style="color: #66cc66;">&#91;</span>currentImage<span style="color: #66cc66;">&#93;</span>;
	imageLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>urlRequ<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>&#8220;switchImage&#8221; is invoked by the Timer we established previously.  The function this method is to set up our eventual transition from one image to the next, grab the next image from our Array and begin to load it into our Loader instance on the Stage, and keep track of what position we are at in our Array.  To accomplish this, we first &#8220;draw()&#8221; the entire Stage to our &#8220;imageBitmapData&#8221; instance.  This data is then assigned to the &#8220;imageBitmap&#8221; bitmapData property, effectively duplicating the visible data within our Loader instance.  This switch from Loader to Bitmap is in no way apparent to the viewer.  We also switch the alpha property of out Bitmap to 1, ensuring that it is completely visible.</p>
<p>We then manage our &#8220;currentPosition&#8221; variable by checking the current value against the Length of the Array.  If we have reached the end, we simply revert to a value of &#8220;0&#8243; causing an infinite loop.</p>
<p>All we have to do then is change the &#8220;url&#8221; property of our URLRequest object and then invoke another load() upon &#8220;imageLoader&#8221;.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> imageLoaded<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>
	imageTween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span>imageBitmap, <span style="color: #ff0000;">&quot;alpha&quot;</span>, Regular.<span style="color: #006600;">easeIn</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This is the last method we have in our little widget.  &#8220;imageLoaded&#8221; is fired by an Event.COMPLETE when a loading image is finally loaded up.  At this point, we simply use Tweener to tween the alpha of our Bitmap (displaying the previous image) down to 0, revealing the freshly loaded image beneath.</p>
<p>I recommend using <a href="http://code.google.com/p/swfobject/">SWFObject</a> to embed the module into your website. </p>
<p>Here is the full PHP code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$firstrun</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;front_images&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.gif&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.png&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$firstrun</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$files</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$firstrun</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$files</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$files</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Here is the full ActionScript class:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Loader</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">TimerEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Timer</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLLoader</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">Tween</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">easing</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SlideShow <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> appPath:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imgDur:<span style="color: #0066CC;">int</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> currentImage:<span style="color: #0066CC;">int</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> urlRequ:URLRequest;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> urlLoad:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageArray:<span style="color: #0066CC;">Array</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageBitmap:Bitmap;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageBitmapData:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageLoader:Loader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageTimer:Timer;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageTween:Tween;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SlideShow<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: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">appPath</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				appPath = root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">appPath</span>;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				appPath = <span style="color: #ff0000;">&quot;http://yourwebsite.com/&quot;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">imgDur</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				imgDur = root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">imgDur</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">1000</span>;;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				imgDur = <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">1000</span>;
			<span style="color: #66cc66;">&#125;</span>
			gatherFiles<span style="color: #66cc66;">&#40;</span><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> gatherFiles<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			urlRequ = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			urlRequ.<span style="color: #0066CC;">url</span> = appPath + <span style="color: #ff0000;">&quot;gatherFrontImages.php&quot;</span>;
			urlLoad = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			urlLoad.<span style="color: #006600;">dataFormat</span> = flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLLoaderDataFormat</span>.<span style="color: #0066CC;">TEXT</span>;
			urlLoad.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, urlComplete<span style="color: #66cc66;">&#41;</span>;
			urlLoad.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>urlRequ<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> urlComplete<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>
			imageArray = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">data</span>.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;,&quot;</span><span style="color: #66cc66;">&#41;</span>;
			currentImage = imageArray.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;">1</span>;
			imageLoader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			imageLoader.<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>, imageLoaded<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>imageLoader<span style="color: #66cc66;">&#41;</span>;
			imageBitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span><span style="color: #66cc66;">&#41;</span>;
			imageBitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>imageBitmap<span style="color: #66cc66;">&#41;</span>;
			switchImage<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> TimerEvent<span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			imageTimer = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span>imgDur<span style="color: #66cc66;">&#41;</span>;
			imageTimer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span>, switchImage<span style="color: #66cc66;">&#41;</span>;
			imageTimer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><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> switchImage<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:TimerEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			imageBitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
			imageBitmap.<span style="color: #006600;">bitmapData</span> = imageBitmapData;
			imageBitmap.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">1</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>currentImage <span style="color: #66cc66;">&lt;</span> imageArray.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				currentImage++;
			<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
				currentImage = <span style="color: #cc66cc;">0</span>;
			<span style="color: #66cc66;">&#125;</span>
			urlRequ.<span style="color: #0066CC;">url</span> = appPath + <span style="color: #ff0000;">&quot;path/to/images/&quot;</span> + imageArray<span style="color: #66cc66;">&#91;</span>currentImage<span style="color: #66cc66;">&#93;</span>;
			imageLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>urlRequ<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> imageLoaded<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>
			imageTween = <span style="color: #000000; font-weight: bold;">new</span> Tween<span style="color: #66cc66;">&#40;</span>imageBitmap, <span style="color: #ff0000;">&quot;alpha&quot;</span>, Regular.<span style="color: #006600;">easeIn</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-3/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Simple AS3 Slideshow Widget: Part 2</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-2/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-2/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 16:34:30 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=512</guid>
		<description><![CDATA[In Part 1, we had a look at the basic structure of what we are working toward, including a PHP file to read images from a directory and return a list of images to Flash, the setup of our FLA, &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-1/">Part 1</a>, we had a look at the basic structure of what we are working toward, including a PHP file to read images from a directory and return a list of images to Flash, the setup of our FLA, and the basic construction of our document class. This widget, being so simple, will only require the document class.</p>
<p>We will now go through each method and describe what is happening&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SlideShow<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: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">appPath</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		appPath = root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">appPath</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
		appPath = <span style="color: #ff0000;">&quot;http://yourwebsite.com/&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">imgDur</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		imgDur = root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">imgDur</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">1000</span>;;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
		imgDur = <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">1000</span>;
	<span style="color: #66cc66;">&#125;</span>
	gatherFiles<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>There are a few things to set up in our constructor function.  These values can be passed in through flashvars or hard-coded into your class.  We are being super flexible and allowing the user to input these values upon embed.  For a short explanation of what is going on here, have a look at my <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/testing-flash-projects-w-dynamic-variables/">previous post</a>.</p>
<p>We now assign values to the &#8220;appPath&#8221; and &#8220;imgDur&#8221; variables.  &#8220;appPath&#8221; is simply the path to our actual application or website.  We will use this to construct both calls to the PHP file and also the images themselves.  &#8220;imgDur&#8221; is a setting that specifies how long each image should persist on the screen before fetching another.  We then call &#8220;gatherFiles()&#8221; after these values are established.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Loader</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">TimerEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Timer</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLLoader</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">Tween</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">transitions</span>.<span style="color: #006600;">easing</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SlideShow <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> appPath:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imgDur:<span style="color: #0066CC;">int</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> currentImage:<span style="color: #0066CC;">int</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> urlRequ:URLRequest;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> urlLoad:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageArray:<span style="color: #0066CC;">Array</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageBitmap:Bitmap;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageBitmapData:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageLoader:Loader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageTimer:Timer;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> imageTween:Tween;</pre></td></tr></table></div>

<p>As we step through this and encounter new variables, they will of course need to be defined and datatyped properly at the beginning of our class.  We will also need to import any other classes we need within our package.  The full list of import statements and variable declarations is included here for the sake of overview.</p>
<p>An important thing to note here, is that we are importing classes that are native to Flash, but are also importing the excellent &#8220;Tweener&#8221; packages which can be found at <a href="http://code.google.com/p/tweener/">Google Code</a>.  You could use the build in tween classes, but Tweener is a lot more flexible and provides much more control.</p>
<p>Now, on to our data loading methods!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> gatherFiles<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	urlRequ = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	urlRequ.<span style="color: #0066CC;">url</span> = appPath + <span style="color: #ff0000;">&quot;gatherFrontImages.php&quot;</span>;
	urlLoad = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	urlLoad.<span style="color: #006600;">dataFormat</span> = flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLLoaderDataFormat</span>.<span style="color: #0066CC;">TEXT</span>;
	urlLoad.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, urlComplete<span style="color: #66cc66;">&#41;</span>;
	urlLoad.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>urlRequ<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Our goal with this method is to create a connection to the PHP file and establish a handler for the results.  In order to do this, we will use the &#8220;URLLoader&#8221; class.  URLLoader has a method called &#8220;load&#8221; which requires a &#8220;URLRequest&#8221; object.  URLRequest has a &#8220;url&#8221; property which we set using a combination of the &#8220;appPath&#8221; variable defined upon initialization and the location and name of our PHP file.  We also set the &#8220;dataFormat&#8221; property of the URLLoader to &#8220;flash.net.URLLoaderDataFormat.TEXT&#8221;.  This will ensure that the data we receive is properly interpreted as text.  Finally, we add an event listener to watch for an &#8220;Event.COMPLETE&#8221; to our URLLoader and invoke the &#8220;load()&#8221; method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> urlComplete<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>
	imageArray = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">data</span>.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;,&quot;</span><span style="color: #66cc66;">&#41;</span>;
	currentImage = imageArray.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;">1</span>;
	imageLoader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	imageLoader.<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>, imageLoaded<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>imageLoader<span style="color: #66cc66;">&#41;</span>;
	imageBitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span><span style="color: #66cc66;">&#41;</span>;
	imageBitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>imageBitmap<span style="color: #66cc66;">&#41;</span>;
	switchImage<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> TimerEvent<span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	imageTimer = <span style="color: #000000; font-weight: bold;">new</span> Timer<span style="color: #66cc66;">&#40;</span>imgDur<span style="color: #66cc66;">&#41;</span>;
	imageTimer.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TimerEvent.<span style="color: #006600;">TIMER</span>, switchImage<span style="color: #66cc66;">&#41;</span>;
	imageTimer.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>&#8220;urlComplete&#8221; is the method that fires off once our URLLoader request is returned to Flash.  We are doing four main things here for the final setup of our slideshow.  </p>
<ol>
<li>First, we use the &#8220;split()&#8221; method to assign each file name to an Array called &#8220;imageArray&#8221;.  We access the returned data (comma-delimited string) through the data property of the event target.  The &#8220;currentImage&#8221; variable keeps track of which image is being displayed later on.  We now set this to the Array length minus one.  This provides us with the final index of our Array.</li>
<li>Next, we will set up our display objects and add them to the display list.  We create a Loader instance &#8220;imageLoader&#8221; to hold our loaded image and display it upon the Stage.  We also add an event listener to the &#8220;contentLoaderInfo&#8221; property of our Loader instance.  This will enable us to detect when the load has completed so that we can safely display the next image.</li>
<li>Similar to the Loader instance, we now create a new BitmapData object &#8220;imageBitmapData&#8221; matching the size of our Stage.  This will be used later on during image transitions and will feed a Bitmap object &#8220;imageBitmap&#8221; that we now create and add to the Stage.</li>
<li>Finally, we set up a Timer  to run based off of the &#8220;imgDur&#8221; variable set upon initialization.  We just need to add an event listener to the Timer to handle each new image load and then invoke the &#8220;start()&#8221; method to get things rolling.  Note that I am also manually triggering the &#8220;switchImage&#8221; method so we do not have to wait a full tick before our first image is shown.</li>
</ol>
<p>Now we have our data imported and arranged nicely.  Our structures and display list are all established.  Everything is set up to begin actually displaying these images upon the Stage.  In <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-3/">Part 3</a>, we will examine the two remaining methods and have a look at the full, completed class structure.</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simple AS3 Slideshow Widget: Part 1</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-1/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-1/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 23:48:38 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=504</guid>
		<description><![CDATA[This is a simple example of how to build a dynamic slideshow widget in Flash using ActionScript 3.0 such as the one seen here. The first thing you&#8217;ll need to do is set up an FLA with the properties you&#8217;d &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a simple example of how to build a dynamic slideshow widget in Flash using ActionScript 3.0 such as the one seen <del datetime="2009-08-29T00:52:50+00:00">here</del>.</p>
<p>The first thing you&#8217;ll need to do is set up an FLA with the properties you&#8217;d like to exhibit.   Stage resolution is set to 500&#215;300 with a black background.  This will vary depending on the size of your generated images.  Be sure that your FLA is set to use ActionScript 3.0 and declare your document class, in this case &#8220;SlideShow&#8221;.</p>
<p>Let&#8217;s set up a PHP file to read from the directory of our choosing and return a list of images to us.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$firstrun</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;images&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>So, here we declare some variables. &#8220;$firstrun&#8221; to determine where we are in our loop, and &#8220;$files&#8221; to hold the comma-delimited list the loop will produce.  &#8220;$dir&#8221; is a directory reference for our image directory.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.gif&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;.png&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$firstrun</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$files</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$firstrun</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$files</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$files</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The next part is pretty simple as well.  We create &#8220;$files&#8221; and populate it with all of the files in our directory.  Next, we simply loop over each item and look for certain character sequences to determine whether we should include a particular file in our list of images.  You can see that the &#8220;$firstrun&#8221; Boolean is used here to determine comma placement for each item.</p>
<p>It is assumed at this point that we have also generated a set of images to use in our slide show and have dumped them into our &#8220;images&#8221; directory on the server.</p>
<p>So now it&#8217;s time to create an ActionScript class to use as the FLA document class.  We called this class &#8220;SlideShow&#8221; in our FLA so this is the exact name we will need to give the file &#8220;SlideShow.as&#8221;.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SlideShow <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SlideShow<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: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Here is the basic setup for our SlideShow class.  It extends flash.display.Sprite so we have to be sure to import that in our package.  Planning our class, we are going to need to define a few different methods:</p>
<p><strong>gatherFiles()</strong><br />
This will be used to create a connection to the server and run the PHP code we previously created.</p>
<p><strong>urlComplete()</strong><br />
Will handle the processing of the comma-delimited String which is returned by PHP and the setup of our display objects on the Stage.</p>
<p><strong>switchImage()</strong><br />
Will handle the image management and loading features.</p>
<p><strong>imageLoaded()</strong><br />
This will serve to process our image transitions and is triggered as each image load completes.</p>
<p>In <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-2/">Part 2</a>, we will look at each of these methods in detail.</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2009/01/simple-as3-slideshow-widget-part-1/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Testing Flash Projects w/ Dynamic Variables</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2009/01/testing-flash-projects-w-dynamic-variables/</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2009/01/testing-flash-projects-w-dynamic-variables/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 22:39:19 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=514</guid>
		<description><![CDATA[Many of the Flash modules and widgets I write are part of a larger system. Normally, some sort of ID or other variable piece of data will need to be passed in as flashvars upon initialization to allow the SWF &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2009/01/testing-flash-projects-w-dynamic-variables/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Many of the Flash modules and widgets I write are part of a larger system.  Normally, some sort of ID or other variable piece of data will need to be passed in as flashvars upon initialization to allow the SWF to function correctly, making the appropriate data calls and so forth.  When testing in the IDE, however, you are separated from the larger application and that data does not exist.  </p>
<p>A simple way to test such items in the standalone Flash Player is to check whether those variables are being passed in&#8230; if not- simply use your test variables.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">appPath</span> <span style="color: #66cc66;">!</span>= <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	appPath = root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">appPath</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
	appPath = <span style="color: #ff0000;">&quot;http://yourwebsite.com/somepath/&quot;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This, for example, might be included within the document class constructor function.  Easy and flexible!</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2009/01/testing-flash-projects-w-dynamic-variables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

