<?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>Carlo Alducente&#039;s Blog &#187; Flash</title>
	<atom:link href="http://labs.alducente.com/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.alducente.com</link>
	<description></description>
	<lastBuildDate>Thu, 12 Nov 2009 01:04:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Flash Shape Detection</title>
		<link>http://labs.alducente.com/2009/11/10/flash-shape-detection/</link>
		<comments>http://labs.alducente.com/2009/11/10/flash-shape-detection/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 02:08:41 +0000</pubDate>
		<dc:creator>alducente</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[gesture]]></category>
		<category><![CDATA[shape detection]]></category>

		<guid isPermaLink="false">http://labs.alducente.com/?p=166</guid>
		<description><![CDATA[I&#8217;ve playing with a lot of motion/gesture detection in flash lately, and this week I got into some shape detection based on user input. In this demo, I used the &#8220;difference&#8221; blend mode to compare the user&#8217;s drawing with a bunch of vector shapes that I&#8217;ve baked in to the swf file. Press down, drag, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve playing with a lot of motion/gesture detection in flash lately, and this week I got into some shape detection based on user input. In this demo, I used the <a href="http://labs.alducente.com/2009/10/16/blendmode-difference-and-why-its-awesome/" target="_self">&#8220;difference&#8221; blend mode</a> to compare the user&#8217;s drawing with a bunch of vector shapes that I&#8217;ve baked in to the swf file.</p>
<p>Press down, drag, and release when your doodle is done. Try to draw the 4 shapes and test out its accuracy.</p>
<p>
<object width="400" height="350">
<param name="movie" value="http://labs.alducente.com/wp-content/uploads/2009/11/shapes.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="400" height="350" src="http://labs.alducente.com/wp-content/uploads/2009/11/shapes.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>When you release the mouse, the shape it detects should light up, if it doesn&#8217;t recognize it then none of the 4 shapes should light up. What I like about this method is that you don&#8217;t need to &#8220;close&#8221; the shapes you draw. You can draw a spiral and it should detect that it&#8217;s a circle.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.alducente.com/2009/11/10/flash-shape-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Globequest</title>
		<link>http://labs.alducente.com/2009/10/12/globequest/</link>
		<comments>http://labs.alducente.com/2009/10/12/globequest/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 21:24:50 +0000</pubDate>
		<dc:creator>alducente</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[A World Of Wonders]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Globequest]]></category>

		<guid isPermaLink="false">http://labs.alducente.com/?p=110</guid>
		<description><![CDATA[A World of Wonders has just launched Globequest, a game that lets you &#8220;travel&#8221; around the world to learn about different cultures and places. Learn more about the television series on their website. While developing the game was loads of fun, there were a couple challenges that we had to overcome in order to get [...]]]></description>
			<content:encoded><![CDATA[<p>A World of Wonders has just launched <strong><a href="http://www.aworldofwonders.tv/games/globequest.php" target="_blank" onclick="urchinTracker('/outgoing/www.aworldofwonders.tv/games/globequest.php?referer=');">Globequest</a></strong>, a game that lets you &#8220;travel&#8221; around the world to learn about different cultures and places. Learn more about the television series on <a href="http://www.aworldofwonders.tv/" target="_blank" onclick="urchinTracker('/outgoing/www.aworldofwonders.tv/?referer=');">their website</a>.</p>
<p style="text-align: center;"><a href="http://www.aworldofwonders.tv/games/globequest.php" target="_blank" onclick="urchinTracker('/outgoing/www.aworldofwonders.tv/games/globequest.php?referer=');"><img class="aligncenter size-full wp-image-115" title="Globequest Title Screen" src="http://labs.alducente.com/wp-content/uploads/2009/10/Untitled-11.jpg" alt="Globequest Title Screen" width="400" height="300" /></a></p>
<p>While developing the game was loads of fun, there were a couple challenges that we had to overcome in order to get this game off the ground&#8230;(OH SNAP! See what I did there? off the ground? traveling? airplane? no?&#8230;okay)</p>
<p>After being presented with the idea, the first thing that came to mind was how to manage the HUGE map the player had to travel around in. I&#8217;m talkin&#8217; loading and moving a 6400&#215;1600 bitmap without sacrificing image quality or performance.</p>
<p>Many tests later, we decided that the best way to solve the filesize issue was to seperate the map into 800&#215;600 tiles, keeping low resolution tiles embedded in the swf file so the player can start the game as soon as possible. While the player travels, the high resolution tiles are being loaded in the background, replacing the low res images one by one as they finish loading. Not only does this reduce the total filesize of the main swf, but it also lets the player continue without having to wait for the giant map to load.</p>
<p style="text-align: center;"><a style="text-decoration: none;" href="http://www.aworldofwonders.tv/games/globequest.php" target="_blank" onclick="urchinTracker('/outgoing/www.aworldofwonders.tv/games/globequest.php?referer=');"><img class="aligncenter size-full wp-image-118" title="Globequest Big Map" src="http://labs.alducente.com/wp-content/uploads/2009/10/Untitled-2.jpg" alt="Globequest Big Map" width="400" height="300" /></a></p>
<p>As for performance, most of us know that moving something as big as 6400&#215;1600 around on screen can be choppy. To improve the animation, I used the display object&#8217;s scrollRect property. For those who aren&#8217;t familiar with this handy feature, it basically acts like a mask, displaying only a section of a display object on screen but with way better performance than a mask. <a href=" http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#scrollRect" target="_blank">Read more about it in the docs here</a>.</p>
<p><strong>So that takes care of the map, but what about the mini games?</strong></p>
<p style="text-align: center;"><a href="http://www.aworldofwonders.tv/games/globequest.php" target="_blank" onclick="urchinTracker('/outgoing/www.aworldofwonders.tv/games/globequest.php?referer=');"><img class="aligncenter size-full wp-image-121" title="Globequest Puzzle" src="http://labs.alducente.com/wp-content/uploads/2009/10/Untitled-3.jpg" alt="Globequest Puzzle" width="400" height="300" /></a></p>
<p>In order to keep the games organized, each one is a separate swf file that gets loaded. This let&#8217;s me encapsulate each mini game, keeping its functionality hidden from the rest of the game. A manager had to be created in order to keep track of all the different games and is in charge of displaying a game when needed, communicating the user&#8217;s performance to the main swf, and cleaning up after a game so the game engine can be reused.</p>
<p><strong>Videos&#8230;so many videos&#8230;</strong></p>
<p style="text-align: center;"><strong><a href="http://www.aworldofwonders.tv/games/globequest.php" target="_blank" onclick="urchinTracker('/outgoing/www.aworldofwonders.tv/games/globequest.php?referer=');"><img class="aligncenter size-full wp-image-124" title="Globequest Video" src="http://labs.alducente.com/wp-content/uploads/2009/10/Untitled-4.jpg" alt="Globequest Video" width="400" height="300" /></a><br />
</strong></p>
<p>For the videos, we wanted to do something simple, using only basic controls to toggle between play and pause states plus a couple events that we can listen for. The FLVPlayback component, while convenient, has too many bells and whistles for our purpose and using the Video class didn&#8217;t give us the amount of control that we wanted. So I decided to go with the built-in VideoPlayer class, which is also a subclass of the Video object but a lot simpler than the FLVPlayback component.</p>
<p><strong>#$%@#!!!</strong></p>
<p>While this wasn&#8217;t an issue, it was something that was completely new to me and thought I&#8217;d share the experience. Since this is a children&#8217;s game after all, we needed to make sure that text inputs filter out &#8220;no-no&#8221; words. Luckily, there&#8217;s only one text input in the entire game (*high-five!). Instead of clearing the field when a bad word is detected, I chose to just disable the &#8220;go&#8221; button. This makes it less frustrating for children with names like &#8220;Dickson&#8221;.</p>
<p style="text-align: center;"><a style="text-decoration: none;" href="http://www.aworldofwonders.tv/games/globequest.php" target="_blank" onclick="urchinTracker('/outgoing/www.aworldofwonders.tv/games/globequest.php?referer=');"><img class="aligncenter size-full wp-image-125" title="Globequest Player: Dickson" src="http://labs.alducente.com/wp-content/uploads/2009/10/Untitled-5.jpg" alt="Globequest Player: Dickson" width="400" height="102" /></a></p>
<p>Now, how am I suppose to detect inappropriate words? Should I just type out every word I could think of?&#8230;.Interwebz to the rescue!!! <a href="http://www.noswearing.com/list.php" target="_blank" onclick="urchinTracker('/outgoing/www.noswearing.com/list.php?referer=');">Check out the list</a>. Now the only thing I needed to do was copy the entire list and write a quick script to format it the way I want, instant digital earmuffs.</p>
<p>So in the end, I would have to say that this project was probably one of the biggest I had the opportunity to code on my own (yes, I&#8217;m a big boy now). I had a chance to take my time, lay out an architecture, and execute smoothly and with ease. While there were some speed bumps along the way, mostly flash &#8220;gotchas&#8221;, there was definitely a lot to learn from this project.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.alducente.com/2009/10/12/globequest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash forms and how to make them less annoying to make</title>
		<link>http://labs.alducente.com/2008/11/21/flash-forms-and-how-to-make-them-less-annoying-to-make/</link>
		<comments>http://labs.alducente.com/2008/11/21/flash-forms-and-how-to-make-them-less-annoying-to-make/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 20:26:27 +0000</pubDate>
		<dc:creator>alducente</dc:creator>
				<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Forms]]></category>

		<guid isPermaLink="false">http://labs.alducente.com/?p=52</guid>
		<description><![CDATA[I&#8217;ve never been a big fan of creating forms in flash, like many others I would rather build an html form and let the backend guys deal with all the validating. But sometime it&#8217;s just unavoidable, specially when your entire site is in flash, popping open an html form is kinda dinky and not very [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve never been a big fan of creating forms in flash, like many others I would rather build an html form and let the backend guys deal with all the validating. But sometime it&#8217;s just unavoidable, specially when your entire site is in flash, popping open an html form is kinda dinky and not very good for consistency.</p>
<p>Here&#8217;s a couple things that I found made my life easier when creating forms in flash.</p>
<p><strong>Email Validation<br />
</strong>Here&#8217;s a good function that I snatched from a <a href="http://www.senocular.com/" target="_blank" onclick="urchinTracker('/outgoing/www.senocular.com/?referer=');">senocular</a> forum thread. Using AS3 regular expressions, it returns true if an email is valid and false if it&#8217;s not:</p>
<pre>function isValidEmail(email:String):Boolean {
	var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
	return emailExpression.test(email);
}</pre>
<p>All you have to do is pass the email in the parameter like so:</p>
<pre>trace(isValidEmail("carlo@alducente.com")) //traces "true"
trace(isValidEmail("woot!")) //traces "false"</pre>
<p><strong>Checking For Empty Fields<br />
</strong>This isn&#8217;t a big issue but found that it&#8217;s good to keep reminding myself that if text in a field is ==&#8221;" or == null, it doesn&#8217;t necessarily mean that it&#8217;s not empty.</p>
<p>Previously, in order to check for empty fields, i would always just check if the string is empty or equal to null, like so:</p>
<pre>if([string] == "" || [string] == null){
	//[string] is empty, throw a big fat bolded error.
}</pre>
<p>I did this for quite a while until i realized that people can still put in spaces only and it will bypass my validation because technically, the string is not empty. It&#8217;s got one (or more) spaces in it only. So here&#8217;s a quick function that I hacked together:</p>
<pre>function isNotEmpty(info:String):Boolean{
	var noSpaces:Array = info.split(" ");
	var a:uint;
	for (a = 0; a &lt; noSpaces.length;a++ ){
		if (noSpaces[a] != ""){
			return true;
		}
	}
	return false;
}</pre>
<p>Using the split() method of a string, i seperate the string into an array wherever there is a space. So if I call the function on &#8220;Carlo is blogging&#8221;, i get an array back that looks like this: ["Carlo", "is", "blogging"]. I can then loop through the array and check if there are any empty (&#8220;&#8221;) values in the array. If the Array is full of empty values, then the string is empty (return false), but if it finds at least one real value, return true.</p>
<p><strong>And the best for last: TABBING!! AAAHHHHH!!!!<br />
</strong>I&#8217;m probably the worst at remembering the tabbing order of my forms in flash. Just when you think you&#8217;re done with a form, the QA guy hits the &#8220;TAB&#8221; button and BLAM! You&#8217;re selection goes from the &#8220;First Name&#8221; field to some random movieclip and puts you to shame with a thick ugly yellow border around that movieclip.</p>
<p>There are two ways you can specify the tabbing order. You can do it by selecting the object you want to add tabbing on to, and going to Window&gt;Other Panels&gt;Accessibility. A window will popup with a &#8220;Tab index&#8221; field. There you can put in a number depending on the order of the tabbing. So if you want to make a text field the first one in the tabbing order, you just put 1 in that field.</p>
<p>You can also specify tabbing order through code, in AS3 objects have a &#8220;tabIndex&#8221; property, you can do the same thing above and give it a numerical value.</p>
<p>The one &#8220;gotcha&#8221; I always encounter is having random movieclips be part of the tabbing, highlighting it with a yellow border. The simplest solution to this is disabling the tabbing for that  movieclip by using the &#8220;tabEnabled&#8221; property.</p>
<pre>
myMovieClip.tabEnabled = false; //keeps it out of the tab order.
</pre>
<p>Any buttons on stage will automatically get added to the tabbing order, even if it&#8217;s originally a movieclip and you set its &#8220;buttonMode&#8221; property to true, that&#8217;s how I usually get that yellow border.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.alducente.com/2008/11/21/flash-forms-and-how-to-make-them-less-annoying-to-make/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
